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

Issue warning if too many figures are open #1919

Merged
merged 2 commits into from May 16, 2013

Conversation

mdboom
Copy link
Member

@mdboom mdboom commented May 13, 2013

Users often ask me why they are running out of memory when plotting in loops, and this is because they are not calling plt.close when using pyplot. I wonder whether it might make sense to emit a warning above say 20 plots saying that the number of open figures has now exceeded 20, and that the user may want to close some to avoid running out of memory. I just made up the value of 20, but I was trying to think above what value it's unlikely the user deliberately has this many figures open. This could be an RC parameter so that users who do want to open 1000 figures (and have the RAM for it) can.

@pelson
Copy link
Member

pelson commented Apr 18, 2013

I'm 👍 for a solution which makes it obvious to noobs what is wrong, but allows the more experienced folk to get around.

Nice idea @astrofrog.

@mdboom
Copy link
Member

mdboom commented Apr 18, 2013

Yes -- it's an interesting idea. I'm going to tentatively milestone this as 1.3.x (not as a blocker), because I think it would be nice to have and fairly simple to implement. It also should get lots of release candidate testing on the other hand, since it feels like something that someone might have a legit problem with, though I'm not creative enough to guess exactly what.

@ghost ghost assigned mdboom May 13, 2013
@@ -666,6 +666,7 @@ def __call__(self, s):
'figure.edgecolor': ['w', validate_color], # edgecolor; white
'figure.frameon': [True, validate_bool],
'figure.autolayout': [False, validate_bool],
'figure.max_num_figures': [20, validate_int],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe call this "figure.max_open_warning" to show explicitly that it is a warning threshold, not a hard limit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth adding a validate_int_gt_0 validator - then you don't need to check it is positive in pyplot...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scrap that. I remember now that a negative number is important... 😄

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@efiring: Yes, good suggestion on including warning in the name.

mdboom added a commit that referenced this pull request May 16, 2013
Issue warning if too many figures are open
@mdboom mdboom merged commit 3d17d95 into matplotlib:master May 16, 2013
@dragoljub
Copy link

Good Add! I just ran into this and having the warning made it clear how to avoid the memory explosion! 👍

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

Successfully merging this pull request may close these issues.

None yet

5 participants