Page 1 of 1

Memory Leak

Posted: Fri Jul 06, 2018 2:05 pm
by srinin2k
Hi,

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.

Thanks
Sri

Re: Memory Leak

Posted: Mon Jul 09, 2018 1:41 pm
by ArctionKestutis
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.

Re: Memory Leak

Posted: Fri Jul 13, 2018 9:47 am
by ArctionKestutis
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
chart.Dispose();
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.