Title: [Bug]: Memory leak with colorbar.make_axes · Issue #22085 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Memory leak with colorbar.make_axes · Issue #22085 · matplotlib/matplotlib
X Title: [Bug]: Memory leak with colorbar.make_axes · Issue #22085 · matplotlib/matplotlib
Description: Bug summary When using matplotlib.colorbar.make_axes function, plt.close() does not clear the new colorbar axes from memory. Tested for the Qt5 backend only. Maybe related to #22002, at least in the sense that I see no leak for Qt5 when ...
Open Graph Description: Bug summary When using matplotlib.colorbar.make_axes function, plt.close() does not clear the new colorbar axes from memory. Tested for the Qt5 backend only. Maybe related to #22002, at least in th...
X Description: Bug summary When using matplotlib.colorbar.make_axes function, plt.close() does not clear the new colorbar axes from memory. Tested for the Qt5 backend only. Maybe related to #22002, at least in th...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/22085
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Memory leak with colorbar.make_axes","articleBody":"### Bug summary\n\nWhen using `matplotlib.colorbar.make_axes` function, `plt.close()` does not clear the new colorbar axes from memory. Tested for the Qt5 backend only. Maybe related to #22002, at least in the sense that I see no leak for Qt5 when no colorbar axes are added.\n\n### Code for reproduction\n\n```python\n%pylab qt5\r\nfrom matplotlib import colorbar\r\nimport psutil\r\nimport gc\r\n\r\np = psutil.Process()\r\nfor i in range(5):\r\n fig, ax = plt.subplots(1,1)\r\n ax.imshow(random.normal(size=(100,100)))\r\n cax = colorbar.make_axes(ax)\r\n plt.savefig(\"test.png\")\r\n plt.pause(0.1)\r\n plt.close(fig)\r\n del fig\r\n del ax\r\n del cax\r\n gc.collect()\r\n print(p.memory_full_info().uss/1e6)\n```\n\n\n### Actual outcome\n\n250.744832\r\n255.209472\r\n259.514368\r\n264.13056\r\n268.099584\n\n### Expected outcome\n\nConstant memory usage, as is when the line\r\n` cax = colorbar.make_axes(ax)`\r\nis commented out.\n\n### Additional information\n\n_No response_\n\n### Operating system\n\nWindows\n\n### Matplotlib Version\n\n3.4.2\n\n### Matplotlib Backend\n\nQt5Agg (PyQt)\n\n### Python version\n\n3.7.6\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\nfrom source (.tar.gz)","author":{"url":"https://github.com/vdrhtc","@type":"Person","name":"vdrhtc"},"datePublished":"2022-01-02T20:32:35.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/22085/matplotlib/issues/22085"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:8fcdf976-1bb3-a723-59e6-8b1e6bc69010 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D7AA:2121C6:EB9991:141ADB3:6A520087 |
| html-safe-nonce | 2c741608b3592e5d478a726abdb596fc2845295bd0aa8e891d221eac3822e0e5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEN0FBOjIxMjFDNjpFQjk5OTE6MTQxQURCMzo2QTUyMDA4NyIsInZpc2l0b3JfaWQiOiI1MTEwMDQxMzM2MjQyODk3MDMxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | a0ea0df5540c90fa40c5de3426b10f6f483e9d6e37a0255b29358c907bc6964c |
| hovercard-subject-tag | issue:1092095467 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/22085/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e3560f80460ec8dfef0fef0f50b987d52df8fdf271fed65b42370917d61112c9/matplotlib/matplotlib/issues/22085 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e3560f80460ec8dfef0fef0f50b987d52df8fdf271fed65b42370917d61112c9/matplotlib/matplotlib/issues/22085 |
| og:image:alt | Bug summary When using matplotlib.colorbar.make_axes function, plt.close() does not clear the new colorbar axes from memory. Tested for the Qt5 backend only. Maybe related to #22002, at least in th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | vdrhtc |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7aed05249554b889eb33d002851a973eebcc7e91 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width