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.