Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Closed
Milestone
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:
importsysimportmatplotlib.pyplotaspltimportnumpyasnpimportmatplotlib#matplotlib.use('agg')data=np.random.rand(60,60)defplot_expr(plot_name):plt.figure(figsize=(9,8))foriinrange(60):plt.plot(data[i, :])plt.savefig(plot_name)plt.close('all')if__name__=="__main__":print(f'python:{sys.version}')print(f'matplotlib:{matplotlib.__version__}')print(f'backend:{matplotlib.get_backend()}')foriinrange(50):print(f'{i}...')plot_expr(f'leak_{i}')
When running the code withmemory-profiler
, I obtain something like:
Even though I am explicitly calling theplt.close()
function.
When using the'agg'
backend instead of the'MacOSX'
backend by uncommenting line 6, I get:
Which I would expect to be the normal behavior.
As I have been unable to reproduce this on Linux, I assume that the issue is with the macOS backend.
Matplotlib version
- Operating system:
macOS 11.2.1
- Matplotlib version
3.3.4
- Matplotlib backend
MacOSX
- Python version:
3.7.9
I installed Python viavenv
and matplotlib viapip
.
Cheers,
Théotime