cormorack / yodapy

Your Ocean Data Access in Python
https://cormorack.github.io/yodapy/
MIT License
9 stars 10 forks source link

Add close figure to save memory #84

Closed lsetiawan closed 5 years ago

lsetiawan commented 5 years ago

Overview

Calling data_availibility multiple times creates new figures everytime, and they don't auto close, which is a problem. This PR should address this, by closing figure after creation.

coveralls commented 5 years ago

Pull Request Test Coverage Report for Build 245


Totals Coverage Status
Change from base Build 244: 0.0%
Covered Lines:
Relevant Lines: 0

💛 - Coveralls
lsetiawan commented 5 years ago

Nevermind, problem is in the harvester side. Closing...

pshivraj commented 5 years ago

@lsetiawan I had similar issue sometime back with matplotlib, apparently plt.close() doesn't release memory properly. So I would suggest something like this which works:

clear figure first

plt.clf()

then close figure

plt.close(fig)

lsetiawan commented 5 years ago

Can that be in yodapy data_availibility function?

lsetiawan commented 5 years ago

Seems like if I close the plot before return, I get nothing....

pshivraj commented 5 years ago

Makes sense, we cannot close it before the return, won't plt.clf() clear the current plot? I think it should be session level clearance. Documentation says Clear the current figure., should we use this in the beginning of data_availability before even plotting anything to clear any residual figures?

lsetiawan commented 5 years ago

Let's try that! Great idea :) Thanks!