[THIN] KB: CTX106970 - How to Enable User Mode Stack Trace Database for IMA Service to Detect Memory Leaks

  • From: "Jim Kenzig Kenzig.com" <jkenzig@xxxxxxxxx>
  • To: thin@xxxxxxxxxxxxx
  • Date: Sat, 2 Jul 2005 08:03:03 -0700 (PDT)

CTX106970 - How to Enable User Mode Stack Trace Database for IMA Service to 
Detect Memory Leaks 

This document was published at: 
http://support.citrix.com/kb/entry.jspa?externalID=CTX106970 


Document ID: CTX106970, Created on: Jul 1, 2005, Updated: Jul 2, 2005 
Products: Citrix MetaFrame XP 1.0 for Microsoft Windows 2000, Citrix MetaFrame 
XP 1.0 for Microsoft Windows 2003, Citrix Presentation Server 4.0 for Microsoft 
Windows 2000, Citrix Presentation Server 4.0 for Microsoft Windows 2003, Citrix 
MetaFrame Presentation Server 3.0 for Microsoft Windows 2000, Citrix MetaFrame 
Presentation Server 3.0 for Microsoft Windows 2003 
 
Symptoms

Users may experience IMA service leaking memory and heap expansion: ImaSrv.exe 
process consumes more than 100 MB. Sometimes it can be even 500 MB or 1.5 GB. 

Cause

Heap expansion (memory leak) results from some components not freeing 
dynamically allocated heap memory. Over time it results in process growth in 
memory, slow operation, and eventually application hang or crash.

Resolution

To detect the components responsible for memory leaks, the user should enable 
an additional runtime diagnostic called user mode stack trace database. If this 
diagnostic is enabled, an application dump should be generated manually when 
the IMA service process has an unusual size. 

First, you will probably need to download and install Debugging Tools for 
Windows from Microsoft to use the gflags.exe utility:

http://www.microsoft.com/whdc/ddk/debugging/default.mspx

Use the following syntax to enable diagnostic: 

gflags /i ImaSrv.exe +ust +htd

The command should display:

Current Registry Settings for ImaSrv.exe executable are: 00009000
    ust - Create user mode stack trace database
    htd - Enable heap tagging by DLL

Once you have the dump, the diagnostic should be disabled to avoid performance 
degradation.

To disable the diagnostic, use the following command:

gflags /i ImaSrv.exe -ust -htd

This command should have the output:

Current Registry Settings for ImaSrv.exe executable are: 00000000

Another way is to use the GUI interface by launching gflags.exe:



Note: You need to restart the IMA service after enabling or disabling the 
diagnostic.

To verify that gflags.exe was used correctly, Citrix Technical Support 
personnel can open the dump in WinDbg.exe and run the command: 

0:000> !gflag
Current NtGlobalFlag contents: 0x00009000
    ust - Create user mode stack trace database
    htd - Enable heap tagging by DLL

More Information

If you need the diagnostics enabled for another application, replace ImaSrv.exe 
with your application name


Other related posts: