.NET Framework Bookmark and Share   
 index > Building Development and Diagnostic Tools for .Net > Identifying memory usage using Windbg
 

Identifying memory usage using Windbg

Hi,

I'm trying to identify why my application takes up nearly 1GB of memory. According to CLR profiler (and .NET memory profiler) all the managed objects only add up to around 200MB-ish. I took a dump using WinDbg and here's the output I get from !address - summary

0:000> !address -summary

-------------------- Usage SUMMARY --------------------------
    TotSize (      KB)   Pct(Tots) Pct(Busy)   Usage
   3191d000 (  812148) : 38.73%    54.48%    : RegionUsageIsVAD
   25026000 (  606360) : 28.91%    00.00%    : RegionUsageFree
   11afc000 (  289776) : 13.82%    19.44%    : RegionUsageImage
    4600000 (   71680) : 03.42%    04.81%    : RegionUsageStack
      46000 (     280) : 00.01%    00.02%    : RegionUsageTeb
   13567000 (  316828) : 15.11%    21.25%    : RegionUsageHeap
          0 (       0) : 00.00%    00.00%    : RegionUsagePageHeap
       1000 (       4) : 00.00%    00.00%    : RegionUsagePeb
       1000 (       4) : 00.00%    00.00%    : RegionUsageProcessParametrs
       2000 (       8) : 00.00%    00.00%    : RegionUsageEnvironmentBlock
       Tot: 7fff0000 (2097088 KB) Busy: 5afca000 (1490728 KB)

-------------------- Type SUMMARY --------------------------
    TotSize (      KB)   Pct(Tots)  Usage
   25026000 (  606360) : 28.91%   : <free>
   14ae5000 (  338836) : 16.16%   : MEM_IMAGE
    1129000 (   17572) : 00.84%   : MEM_MAPPED
   453bc000 ( 1134320) : 54.09%   : MEM_PRIVATE

-------------------- State SUMMARY --------------------------
    TotSize (      KB)   Pct(Tots)  Usage
   44ad5000 ( 1125204) : 53.66%   : MEM_COMMIT
   25026000 (  606360) : 28.91%   : MEM_FREE
   164f5000 (  365524) : 17.43%   : MEM_RESERVE

Largest free region: Base 570f8000 - Size 03c78000 (61920 KB)

I'm pretty new to Windbg but I can tell that the .NET allocated memory (in RegionUsageIsVAD) is around 800MB and the native (which I presume is RegionUsageHeap) is around 300 MB. Can someone point me in the right direction, based on this?

Thanks,
Amit

AmitG
Amit,

RegionUsageIsVAD isn't necessarily just memory allocated by .Net. It's true that the managed objects are included in this,but RegionUsageIsVAD is essentially memory allocated through VirtualAlloc, so it's possible the memory profilers you used are correct. However, you could compare these results with what SOS (a WinDbg extension for debugging managed code) reports.

In any case, Tess Ferrandez, one of our support engineers, has a great blog with walkthroughs that will help you learn how to troubleshoot memory issues, including use of SOS. I'd start with this one: http://blogs.msdn.com/tess/archive/2008/02/15/net-debugging-demos-lab-3-memory.aspx.

If you're getting dramatically different results from SOS and CLRProfiler then I'd consider that a bug in one or the other. :) If you find that to be the case, and have a repro you can share, we'll be happy to look into it.

Thanks,
Jon

All Replies

  • Tuesday, July 28, 2009 4:55 AMJon LangdonMSFT, OwnerUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Amit,

    RegionUsageIsVAD isn't necessarily just memory allocated by .Net. It's true that the managed objects are included in this,but RegionUsageIsVAD is essentially memory allocated through VirtualAlloc, so it's possible the memory profilers you used are correct. However, you could compare these results with what SOS (a WinDbg extension for debugging managed code) reports.

    In any case, Tess Ferrandez, one of our support engineers, has a great blog with walkthroughs that will help you learn how to troubleshoot memory issues, including use of SOS. I'd start with this one: http://blogs.msdn.com/tess/archive/2008/02/15/net-debugging-demos-lab-3-memory.aspx.

    If you're getting dramatically different results from SOS and CLRProfiler then I'd consider that a bug in one or the other. :) If you find that to be the case, and have a repro you can share, we'll be happy to look into it.

    Thanks,
    Jon
  • Thursday, September 17, 2009 4:33 PMAkshay N S Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    RegionUsageIsVAD == denotes the .NET memory heap
    RegionUsageImage == denotes the memory used by the dlls and exes or due to fragmentation
    RegionUsageHeap == is your native heap

    I hope that helps
Jon Langdon

You can use google to search for other answers

Custom Search

More Threads

• Mdbg/Gui: How add code to examine values of objects?
• Custom CLR Profiler - help with design
• Re: Debugging mscorwks
• mscorlib.dll
• dll base address
• calculate size of the object in memory
• Help!My program sometimes can't exit normally
• help debug a 1.1 process
• COR_ILMETHOD_DECODER and unresolved symbols
• converting .net files to xml