Skip to content

ScottPlot.WPF DispatcherTimer memory leak #1115

@ramsayamarin

Description

@ramsayamarin

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:

PlottableCountTimer.Tick += PlottableCountTimer_Tick;
PlottableCountTimer.Interval = new TimeSpan(0, 0, 0, 0, milliseconds: 10);
PlottableCountTimer.Start();

Metadata

Metadata

Assignees

No one assigned

    Labels

    BUGunexpected behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions