-
Notifications
You must be signed in to change notification settings - Fork 981
Description
ScottPlot Version: 4.1.16
Operating System: Windows 10
Application Type: ScottPlot.WPF
Bug Description:
I noticed a memory leak in my application using JetBrains Memory Profiler tool (dotMemory). I open and close many plots with their associated data during the application lifespan and the memory just keeps increasing indefinitely, I suspect a dispatcher timer created in WpfPlot.xaml.cs at line 43 (PlottableCountTimer) is the cause since it is never disposed after creation (unsubscribe from Tick event and call Stop function) therefore making it impossible to be collected by GC. I suggest making WpfPlot IDisposable to handle proper disposal of PlottableCountTimer.
Currently there is no disposal of PlottableCountTimer_Tick:
ScottPlot/src/controls/ScottPlot.WPF/WpfPlot.xaml.cs
Lines 112 to 114 in 3ead8c2
| PlottableCountTimer.Tick += PlottableCountTimer_Tick; | |
| PlottableCountTimer.Interval = new TimeSpan(0, 0, 0, 0, milliseconds: 10); | |
| PlottableCountTimer.Start(); |