Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Closed
Description
Bug summary
python 3.10.4
While using matplotlib 3.5.1 I have encountered a problem in calling multiple times the function FigureCanvasTkAgg().
Code for reproduction
fromtkinterimport*frommatplotlib.figureimportFigurefrommatplotlib.backends.backend_tkaggimportFigureCanvasTkAggimporttracemallocimportgcdefrepeat(n,fig,root):foriinrange(n):agg=FigureCanvasTkAgg(fig,root).get_tk_widget()agg.destroy()delagggc.collect()defmain():root=Tk()root.geometry("300x300+0+0")fig=Figure(dpi=200)tracemalloc.start()tracemalloc.clear_traces()print(tracemalloc.get_traced_memory())repeat(10,fig,root)print(tracemalloc.get_traced_memory())tracemalloc.clear_traces()print(tracemalloc.get_traced_memory())repeat(20,fig,root)print(tracemalloc.get_traced_memory())tracemalloc.clear_traces()print(tracemalloc.get_traced_memory())repeat(30,fig,root)print(tracemalloc.get_traced_memory())tracemalloc.clear_traces()print(tracemalloc.get_traced_memory())root.mainloop()if__name__=="__main__":main()
Actual outcome
(0, 0)
(42116, 55520)
(0, 0)
(41983, 55387)
(0, 0)
(65031, 78436)
(0, 0)
Expected outcome
(0, 0)
(0, 0)
(0, 0)
(0, 0)
(0, 0)
(0, 0)
(0, 0)
Additional information
No response
Operating system
Windows 10
Matplotlib Version
3.5.1
Matplotlib Backend
module://backend_interagg
Python version
3.10.4
Jupyter version
No response
Installation
No response