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

[Bug]: High memory usage inFigure.savefig #29434

Open
Milestone
@zqianem

Description

@zqianem

Bug summary

When saving figures with large data images (imshow), matplotlib version 3.10.0 uses ~4.2 times the amount of memory, and runs ~2.5 times slower.

Code for reproduction

#!/usr/bin/env -S uv run --with humanize --with numpy --with "matplotlib==3.10"importtracemallocimporthumanizeimportmatplotlib.pyplotaspltimportnumpyasnptracemalloc.start()fig,ax=plt.subplots()ax.imshow(np.zeros((10_000,10_000)))fig.savefig("test.png")_,peak=tracemalloc.get_traced_memory()print(f"Memory usage peaked at{humanize.naturalsize(peak)}")

Actual outcome

Memory usage peaked at 7.2 GB

Expected outcome

Memory usage peaked at 1.7 GB

This is the result when the shebang in the code example is changed to "matplotlib<3.10", or when thefig.savefig("test.png") line is removed.

Additional information

May be related to#28904, although switching the backend to Cairo doesn't affect the results.

Operating system

Arch

Matplotlib Version

3.10.0

Matplotlib Backend

agg

Python version

Python 3.13.0

Jupyter version

No response

Installation

None

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp