ItemDetailViewmodel instance retained in memory: RiaServices template example

Nov 26, 2012 at 2:19 AM
Edited Nov 26, 2012 at 2:22 AM

Hi Tony,

I was having some memory leak issues in my project so I tried to isolate the problem. To start off with - 

  • I created a Silverlight project from RiaServices template available for VS2012.
  • The project runs fine.
  • I made silverlight project as OOB for debugging and memory profiling
  • I ran the memory profiler for the project.
  • On pressing > Edit Item, and instance of ItemDetailViewModel is created
  • After editing and closing the window, when I get the snapshot, the ItemDetailViewModel is retained in memory.
  • If I do Edit Item again on the same item or any other item, another instance is created.
  • Isn't it supposed to release the viewmodel once the editing is done?
  • Please see image in my Skydrive for the Path-To-GC. (using JustTrace from Telerik)

Thanks!

Coordinator
Nov 27, 2012 at 1:55 AM

The object may still be in memory simply because a garbage collection has not taken place.  Try calling GC.Collect and seeing if the instance is still in memory.  If so, it means that something is still referencing it.

Nov 27, 2012 at 3:23 AM

Hi Tony,

I did perform the Garbage collection. The viewmodel is still in the memory. I haven't changed any of your code except from marking the app as OOB. Would you be able to test if it is the case at your end as well?

Coordinator
Nov 27, 2012 at 7:07 PM
Will give this a look. I'm wondering if you are using a ViewModeLocator? What do you think has a reference to your view?