Skip to content

Add plt.close() after plt.savefig() - #114

Merged
mnlevy1981 merged 2 commits into
NCAR:mainfrom
chengz2:plt_close
Oct 5, 2026
Merged

mnlevy1981 merged 2 commits into
NCAR:mainfrom
chengz2:plt_close

Conversation

@chengz2

@chengz2 chengz2 commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

This should prevent memory leak from all the figures being plotted.

plt.savefig('PNG/%s_stats.png'%(var))
else:
plt.show()
plt.close(f)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

todo: open issue ticket to rename f -> fig for consistency with other scripts

@mnlevy1981 mnlevy1981 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM!

@mnlevy1981
mnlevy1981 merged commit 180c6a8 into NCAR:main Oct 5, 2026
1 check passed
@chengz2
chengz2 deleted the plt_close branch October 5, 2026 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants