I am working on a Silverlight 4 project where I get a memory leak, because every time some xaml views load, they create their own instance of the class, which then connects to event triggers and does not receive the garbage collected. Extraction of listeners of events turned out to be too complicated in the circumstances, so I could deal with it like this. So instead, I want the class instance to be reused every time the xaml view is loaded.
To do this, I planned to add a resource dictionary for each project in which this error occurs. My concern is that I do not know when this resource dictionary will be created. When the solution first loads, will it load the project and then the resource dictionary, immediately creating a class to use? Or he will wait until something asks him, and then create it. Will what actually happens create a copy of the class that is reused by everyone who accesses it (as in another copy)?
I also understand that I can host resources in app.xaml, but I need to add many such classes, and this really clutters the area that should not bother this problem.
source share