Hello,
We have a Windows Service (or a console) that hosts multiple AppDomains. We would like to monitor the memory usage of each AppDomain. The Process is of .NET 4.5, is hosted on Windows 7, and is being developed with VS 2013 in C#.
The example we used came from: http://msdn.microsoft.com/en-us/library/system.appdomain.monitoringsurvivedmemorysize(v=vs.100).aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-1
However we noticed the memory values reported are way too low, and suspected that they are being updated even after Gen0, Gen1, and non-blocking Gen2 garbage collection. We expect memory update only after a full and blocking GC collection.
This is the same issue reported few years ago without a workaround in the thread: https://connect.microsoft.com/VisualStudio/feedback/details/765296/appdomain-monitoringsurvivedmemorysize-property-returns-wrong-value-after-gen-0-collection#tabs
In addition, we have tried to implement a solution which handles full GC collection without much success: http://msdn.microsoft.com/en-us/library/system.gc.registerforfullgcnotification(v=vs.110).aspx In this exercise, we were able to capture the real memory usages of the first few AppDomains before they are reset again by other GC collections.
Does anyone else have the same experience and is able to provide a workaround?
Thanks,
Jerry