Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible memory leak in Ipython when using %matplotlib inline #200

Closed
hkristen opened this issue Mar 8, 2017 · 2 comments
Closed

Possible memory leak in Ipython when using %matplotlib inline #200

hkristen opened this issue Mar 8, 2017 · 2 comments

Comments

@hkristen
Copy link

hkristen commented Mar 8, 2017

I am using Jupyter notebooks to access the the ADGCv2 or Opendatencube, as it now is called.
I did some band math, masking and so on with S2A-L1C data and plotted the results using matplotlib. Suddenly I got a MemoryError. When I checked my CentOS machine, all 32GB of memory where permanently allocated. When I restarted the kernel in the notebook, all the memory was freed again.

I investigated this a bit and it seems there is a quite serious memory leak happening when using %matplotlib inline in a Jupyter notebook. Every time I plot a figure with matplotlib, some amount of memory is allocated (e.g. 2GB for a more complex plot) but not freed after the plot is finished. When plotting again the some bahaviour is shown, leading in a bigger notebook to a MemoryError at some point.

I could find a unresolved ticket regarding this problem in the Ipython repo

In the above ticket, it is suggest to use matplotlib.use('agg') instead of %matplotlib inline. This indeed solves the memory leak, but I always need to save the figures to the disk in order to see them. It would be way nicer to see them directly in the notebook.

I am aware that I can restart the kernel when the MemoryError occurs and then go on with my calculations, but this is not a very convenient solution either as I would need to load all the needed products again.

Has anyone else experienced the some problem and/or found a solution?

@omad
Copy link
Member

omad commented Mar 8, 2017

I haven't noticed that issue before, but you could try using %matplotlib notebook instead of inline. It gives an interactive plot that displays in the browser, but will also be saved with it.

Since this doesn't seem to be an issue with datacube-core, this isn't the best spot for this issue so we'd like to close it fairly quickly. But let's leave it open for a day to see if anyone else chimes in with a suggestion.

@omad
Copy link
Member

omad commented Mar 8, 2017

Also, please join our Slack team via http://opendatacube.signup.team/ , there's lots of data cube related discussion and help for any sorts of issues you might run into. The core team is online and pretty responsive during Eastern Australian working hours.

@omad omad closed this as completed Mar 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants