New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Memory leak with colorbar.make_axes #22085
Comments
Oh, also just found #22040, probably mine is a duplicate. The difference is that I do not yet know, how to workaround the problem in my example. |
Perhaps also test the latest matplotlib. There were substantial changes to colorbar for 3.5. FWIW, I don;t know what make_axes is supposed to do in your code. |
OK, I can confirm this when |
If I insert ...
del ax
del cax._colorbar_info
del cax
... then the memory leak goes away. This is defined in matplotlib/lib/matplotlib/colorbar.py Lines 1463 to 1471 in 0c1aa86
and used by constrained_layout. I am not clear why adding a dictionary to an object would leave the dictionary orphaned when the parent is deleted? |
Yes, I found that grid spec helps, too, thank you! |
The culprit is |
@jklymak Thank you very much! |
Bug summary
When using
matplotlib.colorbar.make_axes
function,plt.close()
does not clear the new colorbar axes from memory. Tested for the Qt5 backend only. Maybe related to #22002, at least in the sense that I see no leak for Qt5 when no colorbar axes are added.Code for reproduction
Actual outcome
250.744832
255.209472
259.514368
264.13056
268.099584
Expected outcome
Constant memory usage, as is when the line
cax = colorbar.make_axes(ax)
is commented out.
Additional information
No response
Operating system
Windows
Matplotlib Version
3.4.2
Matplotlib Backend
Qt5Agg (PyQt)
Python version
3.7.6
Jupyter version
No response
Installation
from source (.tar.gz)
The text was updated successfully, but these errors were encountered: