sawyl: (A self portrait)
Working on a bit of code to create a number of complex figures, I noticed that it seemed to leak memory like a sieve: around 7-10MB per figure, causing my already stressed desktop machine to decend into an epic bout of thrashing.

After scrutinising my code, I decided that that problem had to be with matplotlib and started skimming the documentation. I soon realised my mistake: although I'd been saving my figures and deleting the variable associated with them, I hadn't been running clf() and close() before doing so and the memory associated with them wasn't being realised. So I added a couple of lines of code and the memory footprint dropped from multiple GB to a more sustainable 200MB and remained stable for the duration of the run.

Profile

sawyl: (Default)
sawyl

August 2018

S M T W T F S
   123 4
5 6 7 8910 11
12131415161718
192021222324 25
262728293031 

Syndicate

RSS Atom

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Aug. 9th, 2025 04:56 am
Powered by Dreamwidth Studios