none
How do I monitor memory usage of AppDomains in my Process hosted in a Windows Service? RRS feed

  • Question

  • 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

    Thursday, March 27, 2014 3:40 PM

All replies

  • Hi Jerry,

    I am trying to involve someone familiar with this issue to come into this thread. Thank you for your understanding.

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, March 28, 2014 6:35 AM
    Moderator