<h3 dir="auto">Bug summary</h3>
<p dir="auto">When using <code class="notranslate">matplotlib.colorbar.make_axes</code> function, <code class="notranslate">plt.close()</code> does not clear the new colorbar axes from memory. Tested for the Qt5 backend only. Maybe related to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1083953332" data-permission-text="Title is private" data-url="https://github.com/matplotlib/matplotlib/issues/22002" data-hovercard-type="pull_request" data-hovercard-url="/matplotlib/matplotlib/pull/22002/hovercard" href="https://github.com/matplotlib/matplotlib/pull/22002">#22002</a>, at least in the sense that I see no leak for Qt5 when no colorbar axes are added.</p>
<h3 dir="auto">Code for reproduction</h3>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="%pylab qt5
from matplotlib import colorbar
import psutil
import gc

p = psutil.Process()
for i in range(5):
    fig, ax = plt.subplots(1,1)
    ax.imshow(random.normal(size=(100,100)))
    cax = colorbar.make_axes(ax)
    plt.savefig(&quot;test.png&quot;)
    plt.pause(0.1)
    plt.close(fig)
    del fig
    del ax
    del cax
    gc.collect()
    print(p.memory_full_info().uss/1e6)"><pre class="notranslate"><span class="pl-c1">%</span><span class="pl-s1">pylab</span> <span class="pl-s1">qt5</span>
<span class="pl-k">from</span> <span class="pl-s1">matplotlib</span> <span class="pl-k">import</span> <span class="pl-s1">colorbar</span>
<span class="pl-k">import</span> <span class="pl-s1">psutil</span>
<span class="pl-k">import</span> <span class="pl-s1">gc</span>

<span class="pl-s1">p</span> <span class="pl-c1">=</span> <span class="pl-s1">psutil</span>.<span class="pl-v">Process</span>()
<span class="pl-k">for</span> <span class="pl-s1">i</span> <span class="pl-c1">in</span> <span class="pl-en">range</span>(<span class="pl-c1">5</span>):
    <span class="pl-s1">fig</span>, <span class="pl-s1">ax</span> <span class="pl-c1">=</span> <span class="pl-s1">plt</span>.<span class="pl-en">subplots</span>(<span class="pl-c1">1</span>,<span class="pl-c1">1</span>)
    <span class="pl-s1">ax</span>.<span class="pl-en">imshow</span>(<span class="pl-s1">random</span>.<span class="pl-en">normal</span>(<span class="pl-s1">size</span><span class="pl-c1">=</span>(<span class="pl-c1">100</span>,<span class="pl-c1">100</span>)))
    <span class="pl-s1">cax</span> <span class="pl-c1">=</span> <span class="pl-s1">colorbar</span>.<span class="pl-en">make_axes</span>(<span class="pl-s1">ax</span>)
    <span class="pl-s1">plt</span>.<span class="pl-en">savefig</span>(<span class="pl-s">"test.png"</span>)
    <span class="pl-s1">plt</span>.<span class="pl-en">pause</span>(<span class="pl-c1">0.1</span>)
    <span class="pl-s1">plt</span>.<span class="pl-en">close</span>(<span class="pl-s1">fig</span>)
    <span class="pl-k">del</span> <span class="pl-s1">fig</span>
    <span class="pl-k">del</span> <span class="pl-s1">ax</span>
    <span class="pl-k">del</span> <span class="pl-s1">cax</span>
    <span class="pl-s1">gc</span>.<span class="pl-en">collect</span>()
    <span class="pl-en">print</span>(<span class="pl-s1">p</span>.<span class="pl-en">memory_full_info</span>().<span class="pl-s1">uss</span><span class="pl-c1">/</span><span class="pl-c1">1e6</span>)</pre></div>
<h3 dir="auto">Actual outcome</h3>
<p dir="auto">250.744832<br>
255.209472<br>
259.514368<br>
264.13056<br>
268.099584</p>
<h3 dir="auto">Expected outcome</h3>
<p dir="auto">Constant memory usage, as is when the line<br>
<code class="notranslate">    cax = colorbar.make_axes(ax)</code><br>
is commented out.</p>
<h3 dir="auto">Additional information</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Operating system</h3>
<p dir="auto">Windows</p>
<h3 dir="auto">Matplotlib Version</h3>
<p dir="auto">3.4.2</p>
<h3 dir="auto">Matplotlib Backend</h3>
<p dir="auto">Qt5Agg (PyQt)</p>
<h3 dir="auto">Python version</h3>
<p dir="auto">3.7.6</p>
<h3 dir="auto">Jupyter version</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Installation</h3>
<p dir="auto">from source (.tar.gz)</p>
<p dir="auto">Python version: 2.7; Windows version: 7; Matplotlib version 1.2.1</p>
<p dir="auto">I'm making an interactive plot (set with <code class="notranslate">plt.ion()</code>) while some other parts of my script do some calculations, and I update the plot frequently with calls to <code class="notranslate">plt.draw()</code>. I noticed that when I click the figure window of the interactively drawn plot and try to move it around, the figure stops updating and Windows tags the process "Not Responding", but the script continues to run without a problem. If I don't click the figure window, everything is ok.</p>
<p dir="auto">I've read that some people have had this issue before <a href="http://wxpython-users.1045709.n5.nabble.com/matplotlib-amp-wxPython-question-td2358678.html" rel="nofollow">on other forums</a> and they got around the problem by using different backends, but my computer doesn't respond differently to other backends. What can I do?</p>