Memory leak in Silvelright with INotifyDataErrorInfo

by Augustin Šulc and Petr Jerman

We are facing memory leaks in Silverlight with almost every application we make. Although some issues were fixed by Silverlight 4.0.50826.0, there is still one serious leak left.

To reproduce the leak, you only need to create an object that implements INotifyDataErrorInfo interface and them bind any UI element (for example, a TextBlock) to it. When you refresh the object and notify the binding that the source has changed, something is still left in the memory.

This problem is very significant with an ItemsControl bound to a list of objects. If you update the list and fire the NotifyPropertyChanged event (which is very common in any business application with a Refresh button), memory consumption is increased.

In some cases, this can be fixed by adding NotifyOnValidationError=False to the binding definition.

The only reference I’ve found so far about this issue is here. As Yifung Lin from MS stated, “the issue should be fixed for Silverlight 5, and it could potentially be fixed earlier than that in upcoming updates for SL 4”.

Demo of the leak can be found in the attached project. Just run the application, click Refresh several times, and watch memory consumption. Then, remove the implementation of INotifyDataErrorInfo in the DataSrc class, and restart the application.

Tags: Silverlight

1 Comment

  • nikitakova said


    It's a serious problem and really is a kill my application now and we don't know when Ms fix this.
    It's more serious one :|

Add a Comment