Bug report
Bug summary
When creating multiple plots (e.g. in a loop), the allocated memory for the process increases in each iteration even though the figure is cleared each time.
Code for reproduction
import gc
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
for i in range(5000):
fig.clf()
plt.cla()
ax.plot([0,1,2,3,4,5], [0,1,2,3,4,5])
plt.close('all')
plt.close(fig)
gc.collect()
Expected outcome
The allocated memory should not increase in each iteration.
Matplotlib version
- Operating system: Arch Linux
- Matplotlib version (
import matplotlib; print(matplotlib.__version__)): 3.4.2
- Matplotlib backend (
print(matplotlib.get_backend())): TkAgg
- Python version: 3.9.5
- Jupyter version (if applicable):
- Other libraries:
Matplotlib was installed via pip.
Bug report
Bug summary
When creating multiple plots (e.g. in a loop), the allocated memory for the process increases in each iteration even though the figure is cleared each time.
Code for reproduction
Expected outcome
The allocated memory should not increase in each iteration.
Matplotlib version
import matplotlib; print(matplotlib.__version__)): 3.4.2print(matplotlib.get_backend())): TkAggMatplotlib was installed via pip.