How to read the memory snapshot in Visual Studio
I am not a big fan of Visual Studio Snapshot analyzer. There are quite a few complications available if finalization is not properly executed before taking the snapshot. I am not sure how Visual Studio handles that. However, the snapshot you have provided doesn't make much sense for me either.
I would suggest you to download the ANTS memory profiler and investigate this. It comes with a reasonable trial period. By using that, you will be able to see all references to each instance by using it's 'Retention Graph'. It will specifically show you which instances keeps the reference to your objects and also it will show you which objects have implemented Dispose but hasn't call. I guess, it will provide more support to find the root cause for this issue.
Have a look at below pages walkthrough
http://www.red-gate.com/products/dotnet-development/ants-memory-profiler/walkthrough http://www.red-gate.com/products/dotnet-development/ants-memory-profiler/
The Paths to Root view shows the references to this type keeping it from being garbage collected. Since your class is a Xaml page, the reference which keeps the class alive is a CLR handler for the Xaml page. These show up as RefCount Handle.
Count and reference count are indeed not the same. Count is the number of instances, reference count the number of references. Because each instance in your case only has one reference, it makes sense they add up.
For more info:
- https://devblogs.microsoft.com/devops/using-visual-studio-2013-to-diagnose-net-memory-issues-in-production/
- https://docs.microsoft.com/visualstudio/profiling/analyze-memory-usage
- https://docs.microsoft.com/visualstudio/profiling/memory-usage