<img height="1" width="1" style="display:none;" alt="" src="https://dc.ads.linkedin.com/collect/?pid=1005900&amp;fmt=gif">


Tools for creating and analysing .NET application memory dumps

Very often while running performance tests, you might notice issues around memory which could impact various areas of the system under test and also impact the end user. In a .Net environment memory leaks are a very common issue seen while developing and testing software.  When working in a managed environment, memory leaks are less common because the Garbage Collector usually takes care of the memory.  Memory leaks are more likely to happen when unmanaged code is used as it is outside the CLR.

This article shows how to use free tools available to generate a memory dump and analyse it.  Please note that this example is from a Windows 2003 server; in later versions of windows, memory dumps can be generated simply by selecting the process from Windows Task Manager and selecting the ‘Create Dump File’ option.

Creating Memory Dumps

  1. Download procdump from http://technet.microsoft.com/en-gb/sysinternals/dd996900.aspx
  2. Extract contents of the Zip file and you will find an executable called ‘procdump.exe’
  3. Find the process ID of the process from which you want to take the memory dump
    • This can be done by opening windows task manager; for example from the screenshot below we want to create a memory dump of the w3wp process which has 4224 as the process IDtask manager
  4. Open a command prompt window and navigate to the directory where you extracted procdump and type the following command:
    • procdump –ma ProcessID MemoryDumpName
      • Example: procdump –ma 4224 w3wpmemorydump
    • If the capture of the memory dump was successful, you should see a file called w3wpmemorydump.dmp created in the folder where you have the procdump executable
    • The output screen on command prompt should look like this:procmon

Analysing Memory Dumps

  1. Download and Install Debug Diagnostic Tool from here http://www.microsoft.com/en-gb/download/details.aspx?id=26798
  2. From the Debug Diagnostic Tool installation folder or the start menu, open ‘Debug Diagnostic Tool (Analysis Only)’ and click on ‘Add Data Files’ from the open windowdebug diagnostic tool
  3. Navigate to the folder where you have memory dump saved and open it.  It will then add it in the Data Files list.
  4. There are different types of analysis that can now be performed on this memory dump.  For example: Crash/Hang Analysis, Memory Pressure Analyzers, etc..
  5. As an example we will try to analyse the DotNetMemory, select the 2nd line from the analysis scripts window and click on ‘Start Analysis’
  6. After a few seconds a new tab will appear in your internet browser that will look like the screenshots below.  You can browse through the page to view memory contents, objects stored in memory and various other metrics that will help in troubleshooting performance issues.

analysis summary

CLR Information