Title: Memory leak when plotting multiple figures with the macOS backend · Issue #19769 · matplotlib/matplotlib · GitHub
Open Graph Title: Memory leak when plotting multiple figures with the macOS backend · Issue #19769 · matplotlib/matplotlib
X Title: Memory leak when plotting multiple figures with the macOS backend · Issue #19769 · matplotlib/matplotlib
Description: Bug report Bug summary Hi, I believe I have found a memory issue when plotting multiple figures with the macOS backend. Here is a minimal working example: import sys import matplotlib.pyplot as plt import numpy as np import matplotlib #m...
Open Graph Description: Bug report Bug summary Hi, I believe I have found a memory issue when plotting multiple figures with the macOS backend. Here is a minimal working example: import sys import matplotlib.pyplot as plt...
X Description: Bug report Bug summary Hi, I believe I have found a memory issue when plotting multiple figures with the macOS backend. Here is a minimal working example: import sys import matplotlib.pyplot as plt...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/19769
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Memory leak when plotting multiple figures with the macOS backend","articleBody":"\u003c!--To help us understand and resolve your issue, please fill out the form to the best of your ability.--\u003e\r\n\u003c!--You can feel free to delete the sections that do not apply.--\u003e\r\n\r\n### Bug report\r\n\r\n**Bug summary**\r\n\r\nHi,\r\n\r\nI believe I have found a memory issue when plotting multiple figures with the macOS backend.\r\n\r\nHere is a minimal working example:\r\n\r\n```python\r\nimport sys\r\nimport matplotlib.pyplot as plt\r\nimport numpy as np\r\n\r\nimport matplotlib\r\n#matplotlib.use('agg')\r\n\r\ndata = np.random.rand(60, 60)\r\n\r\ndef plot_expr(plot_name):\r\n\r\n plt.figure(figsize=(9, 8))\r\n\r\n for i in range(60):\r\n plt.plot(data[i, :])\r\n\r\n plt.savefig(plot_name)\r\n\r\n plt.close('all')\r\n\r\n\r\nif __name__ == \"__main__\":\r\n\r\n print(f'python: {sys.version}')\r\n print(f'matplotlib: {matplotlib.__version__}')\r\n print(f'backend: {matplotlib.get_backend()}')\r\n\r\n for i in range(50):\r\n print(f'{i}...')\r\n plot_expr(f'leak_{i}')\r\n```\r\n\r\nWhen running the code with `memory-profiler`, I obtain something like:\r\n\r\n\r\nEven though I am explicitly calling the `plt.close()` function.\r\n\r\nWhen using the `'agg'` backend instead of the `'MacOSX'` backend by uncommenting line 6, I get:\r\n\r\n\r\nWhich I would expect to be the normal behavior.\r\n\r\nAs I have been unable to reproduce this on Linux, I assume that the issue is with the macOS backend.\r\n\r\n**Matplotlib version**\r\n\u003c!--Please specify your platform and versions of the relevant libraries you are using:--\u003e\r\n * Operating system: `macOS 11.2.1`\r\n * Matplotlib version `3.3.4`\r\n * Matplotlib backend `MacOSX`\r\n * Python version: `3.7.9`\r\n\r\nI installed Python via `venv` and matplotlib via `pip`.\r\n\r\n\r\nCheers,\r\n\r\nThéotime","author":{"url":"https://github.com/tgrohens","@type":"Person","name":"tgrohens"},"datePublished":"2021-03-25T16:08:15.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":11},"url":"https://github.com/19769/matplotlib/issues/19769"}
| 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:6fdf192c-b02a-a431-1fad-d0c5a7b4c47a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 85D4:1661F0:1AEC63:245FCE:6A525518 |
| html-safe-nonce | c4cbdc95451c351b6d098d6f37a75a7e34ffc50a7163070afefb687aab4fde7c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NUQ0OjE2NjFGMDoxQUVDNjM6MjQ1RkNFOjZBNTI1NTE4IiwidmlzaXRvcl9pZCI6IjI2NDk1MzY2NTM0ODQ1MTI1MzYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | a58265e842956d31e78789394a6f0e26057da8fffb7ea50d5b11bccb4aa6e982 |
| hovercard-subject-tag | issue:841083465 |
| 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/19769/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f2dbcce7c73519b8d2e763c1b48627174f9c8dfb27812b04ce997ec06d7c9098/matplotlib/matplotlib/issues/19769 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f2dbcce7c73519b8d2e763c1b48627174f9c8dfb27812b04ce997ec06d7c9098/matplotlib/matplotlib/issues/19769 |
| og:image:alt | Bug report Bug summary Hi, I believe I have found a memory issue when plotting multiple figures with the macOS backend. Here is a minimal working example: import sys import matplotlib.pyplot as plt... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tgrohens |
| 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