Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

FIX: squash memory leak in colorbar#22089

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

jklymak
Copy link
Member

PR Summary

Closes#22085

I guess I'm not 100% sure why the old code breaks, but this new code does not leak memory.

Tested via

importmatplotlib.pyplotaspltfrommatplotlibimportcolorbarimportpsutilimportgcimportnumpyasnpp=psutil.Process()foriinrange(20):fig,ax=plt.subplots(1,1)ax.imshow(np.random.normal(size=(10,10)))cax,_=colorbar.make_axes(ax)# plt.savefig("test.png")plt.pause(0.1)plt.close(fig)delfigdelcaxdelaxgc.collect()print(p.memory_full_info().uss/1e6)

Before:

66.29785660.760064...86.35596887.8592

Now:

(OK, there actually appears to be a slow memory leak somewhere else, but it isfar slower than this memory leak...)

55.6646451.818496...57.42182457.63072

PR Checklist

Tests and Styling

  • Has pytest style unit tests (andpytest passes).
  • IsFlake 8 compliant (installflake8-docstrings and runflake8 --docstring-convention=all).

Documentation

  • New features are documented, with examples if plot related.
  • New features have an entry indoc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented indoc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).

@jklymakjklymak added this to thev3.5.2 milestoneJan 3, 2022
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
@tacaswelltacaswell merged commit61fa334 intomatplotlib:mainJan 4, 2022
@lumberbot-app
Copy link

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
git checkout v3.5.xgit pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
git cherry-pick -m1 61fa334ea234d665f63c4689b782fddb3c0353a1
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
git commit -am 'Backport PR #22089: FIX: squash memory leak in colorbar'
  1. Push to a named branch:
git push YOURFORK v3.5.x:auto-backport-of-pr-22089-on-v3.5.x
  1. Create a PR against branch v3.5.x, I would have named this PR:

"Backport PR#22089 on branch v3.5.x (FIX: squash memory leak in colorbar)"

And apply the correct labels and milestones.

Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon!

Remember to remove theStill Needs Manual Backport label once the PR gets merged.

If these instructions are inaccurate, feel free tosuggest an improvement.

tacaswell added a commit to tacaswell/matplotlib that referenced this pull requestJan 4, 2022
Merge pull requestmatplotlib#22089 from jklymak/fix-memleak-make-colorbarFIX: squash memory leak in colorbar
QuLogic added a commit that referenced this pull requestJan 4, 2022
…-v3.5.xBackport PR#22089: FIX: squash memory leak in colorbar
@jklymakjklymak deleted the fix-memleak-make-colorbar branchNovember 9, 2022 19:06
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@timhoffmtimhoffmtimhoffm approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
v3.5.2
Development

Successfully merging this pull request may close these issues.

[Bug]: Memory leak with colorbar.make_axes
3 participants
@jklymak@timhoffm@tacaswell

[8]ページ先頭

©2009-2025 Movatter.jp