Memory Leak

A forum dedicated to WPF version of LightningChart Ultimate.

Moderator: Arction_LasseP

Posts: 25
Joined: Thu Jun 18, 2015 9:22 pm

Memory Leak

Post by srinin2k » Fri Jul 06, 2018 2:05 pm


I'm trying to fix a memory leak in our application. Please look at the attached screenshot by the dotmemory tool. Leak is due to DispatchTimer in rendering engine? I'm using the latest WPF chart control.

memleakchart.png (200.02 KiB) Viewed 3839 times

Posts: 383
Joined: Mon Mar 14, 2016 9:22 am

Re: Memory Leak

Post by ArctionKestutis » Mon Jul 09, 2018 1:41 pm

Sorry for the late reply. It was busy week so forum was neglected. Writing directly to Support account with SubscriptionID usually result in more speedy answer.

Sorry, but from image is not clear (at least for me) that you have memory leak and what kind.
I would need more description of LightningChart usage here: what kind of objects you have in the chart and how memory leak is manifesting.

When having any mystic problem with the chart, ensure you have a working error/exception handler (subscribe to _chart.ChartError event) in your application which brings those errors visible for the user and tells the reason.

Another issue I would like to remind: LightningChart updates must be done in UI thread. We don't guarantee operation otherwise. That is the way in WinForms and WPF, practically for all UI controls. All UI stuff must be updated in UI thread, otherwise the application is prone to crashing or doing all kind funny stuff.

All the best.

Posts: 383
Joined: Mon Mar 14, 2016 9:22 am

Re: Memory Leak

Post by ArctionKestutis » Fri Jul 13, 2018 9:47 am

When LightingChart's objects are not needed anymore it's good practice to Dispose them to prevent memory leaking.
As it is described in User’s Manual chapter Dispose pattern:

Chart disposing
When you have created the chart in code, and don't need that chart anymore, call
to free the memory of the chart and all its objects, such as series, markers, palette steps...

Objects disposing
If you create objects on the fly, and want to free their memory before exiting the application or disposing the whole chart [with chart.Dispose()] , remove the object from the collection it has been added to, and then call Dispose() for the object.

Hope this helps.