Possible Memory leak

Oystein Bjorke 6 ár síðan 0
This discussion was imported from CodePlex

Scribbles wrote at 2014-02-18 21:36:

I am working on a project which is using oxyplot to create an oscilloscope display. The display works fine and the performance is great, however when we bind our data collection to an OxyPlot LineSeries, the data objects are never deallocated, and after a few hours the application crashes. I used .Net Memory Profiler to confirm this.

The original implementation is using a ConcurrentQueue to provide the ItemsSource, and after adding new data and removing stale data, raised a NotifyPropertyChanged("DataQueue"). I also tried using an array as the ItemsSource and doing a DataQueue.ToArray and NotifyPropertyChanged("DataArray"). In both cases, the DataPoints are never garbage collected .
If, however, I use an ObservableCollection, and clear the data before I replace the collection, then the DataPoints are cleared properly.
The leak also disappears if I remove the binding in the LineSeries ItemsSource.

Am I simply using oxyplot in a way that is not intended (by using NotifyPropertyChanged to redraw a series, rather than using an observable collection)?

The following is a screenshot of the memory profiler references list of expired data, it appears as though the enumerators are not being discarded properly, or that there are event handlers keeping handlers from old data.


objo wrote at 2014-02-27 20:42:

Yes, it looks like something is wrong here. I don't know if this is a problem within the OxyPlot implementation. Ideally, it should not be possible to get into this situation by 'wrong usage'...
Is it possible to create a small example that can reproduce the error and add it to the issues list?

zyhong wrote at 2014-03-06 20:57:

I saw the memory leak happened at example browser as well. in windows, if you keep clicking on different examples, the memory will keep growing.

Scribbles wrote at 2014-03-07 16:13:

I have created an Issue for this at: https://oxyplot.codeplex.com/workitem/10151