I am debugging an issue with high memory usage in a .NET web app using JetBrains dotMemory. The Profiler claims that memory usage in Generation 2 is very high. When I click to "Get Snapshot" however, the memory usage is instantly cleared and I cannot see the contents of Generation 2 in the snapshot.
How can I debug the Generation 2 memory?
To get a memory snapshot dotMemory launches garbage collection, that is how Microsoft Profiling API works. Gen2 objects have been collected by GC, means that there were no references on them and they just waited for GC(2), which happens less often then GC(0). It means that you do not have an issue with high memory usage. It's a CLR's matter when to run GC to free up a memory, if it don't, then there is enough memory.
If you still need to see what objects are they, you can use Memory Traffic View to see objects allocated and collected in a range between two snapshots. Or Snapshots Comparison View to see which objects presented in one snapshot died during getting another.