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

Memory leak when plotting multiple figures with the macOS backend #19769

Closed
@tgrohens

Description

@tgrohens

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:
leak

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:
no_leak

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 version3.3.4
  • Matplotlib backendMacOSX
  • Python version:3.7.9

I installed Python viavenv and matplotlib viapip.

Cheers,

Théotime

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp