-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Closed
Milestone
Description
Hi,
I seem to be getting a memory leak when using the RangeSlider. First noticed it in VS2015 diagnostic tools, then checked with JetBrains dotMemory which confirmed a "Dependency Property Leak". This appears to be a result of calling AddValueChanged in the RangeSlider constructor and not having a matching RemoveValueChanged
DependencyPropertyDescriptor.FromProperty(ActualWidthProperty, typeof(RangeSlider)).AddValueChanged(this, delegate { ReCalculateSize(); });
DependencyPropertyDescriptor.FromProperty(ActualHeightProperty, typeof(RangeSlider)).AddValueChanged(this, delegate { ReCalculateSize(); });
Described here: http://o.oz-code.com/top-3-memory-leak-inducing-pitfalls-of-wpf-programming
I rebuilt MahApps.Metro with the two AddValueChanged lines remove and confirmed the leak is no longer there. I don't know if it was the correct thing to do but my fix for replacing those lines was to override OnPropertyChanged:
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
{
base.OnPropertyChanged(e);
if (e.Property == ActualWidthProperty || e.Property == ActualHeightProperty)
{
ReCalculateSize();
}
}
Thank you for the awesome library!
Regards,
Andrew