Skip to content

[Bug]: plt.figure(), plt.close() leaks memory #23701

Closed
@nschloe

Description

@nschloe

Bug summary

MWE:

import matplotlib.pyplot as plt

while True:
    plt.figure()
    plt.close()

Either run this code and monitor the mem consumption on top, or run

mprof run test.py
mprof plot

(with memory-profiler) to get

screenshot

Might be related to #22448.

Operating system

Ubuntu 22.10

Matplotlib Version

3.5.3

Matplotlib Backend

GTK4Agg

Python version

3.10.6

Jupyter version

No response

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions