Various sources (e.g. this post) make it sound like garbage collection occurs properly for figures created with matplotlib.figure.Figure() but not for figures created with matplotlib.pyplot.figure(). Unfortunately, I haven't been able to find documentation of this.
Is it true that Python will garbage collect old figures created with matplotlib.figure.Figure() that are no longer used? For example...
- If I assign
fig = matplotlib.figure.Figure()inside a function, will the memory for this figure be cleared up when the function ends (assuming I don't do something likereturn fig)? - If I assign
fig = matplotlib.figure.Figure(), will the memory for the figure immediately be cleared up if I then assignfig = 23?
Thank you!
(I apologize if this isn't actually "garbage collection." If so, let me know. )
Edit: fixed typo