How to Enable Full Page Heap for the IMA Service

Summary

The IMA Service sometimes becomes unresponsive or crashes because of a heap corruption.

Background

Heap corruption results from application coding mistakes or corrupt external data.

Although various hotfixes exist, it is not always possible to identify which module (Citrix or non-Citrix) is responsible for heap corruption because the effects of heap corruption usually reveal themselves over time.

Procedure

To detect heap corruption at the moment it occurs, enable additional runtime diagnostics (called full page heap). Enabling this diagnostic generates an application dump.

Download and install Debugging Tools for Windows from Microsoft to use the gflags utility:

Debugging Tools for Windows 32-bit version

Note: Because IMA service is a 32-bit executable even on x64 Windows, you must use gflags.exe from 32-bit Debugging Tools

Note: Below are the directions for running gflags.exe. You do not need to install the debugging tools on the Citrix server if you only need to run gflags.exe from the command line. You may install the debugging tools on a workstation or test server, and then copy only the gflags.exe file from the installation directory onto the Citrix server.

Use the following syntax to enable full page heap:

gflags /p /enable ImaSrv.exe /full — Or — gflags /i ImaSrv.exe +hpa

To verify that gflags has enabled page heap verification, use the following command:

gflags.exe /p — Or — gflags /i ImaSrv.exe

The command displays:

ImaSrv.exe: page heap enabled with flags (full traces)

— Or —

Current Registry Settings for ImaSrv.exe executable are 02000000

After the dump, full page heap is disabled to avoid performance degradation.

To disable full page heap, use the following command:

gflags /p /disable ImaSrv.exe — Or — gflags /i ImaSrv.exe -hpa

To verify that full page heap is disabled, use the following command:

gflags.exe /p — Or — gflags /i ImaSrv.exe

This command has the following output:

No application has page heap enabled

— Or —

Current Registry Settings for ImaSrv.exe executable are 00000000

The same result can be achieved using Graphical User Interface of gflags.exe:

If you do not want to install Debugging Tools for Windows or use gflags.exe, you can modify the registry directly:

Caution! This fix requires you to edit the registry. Using Registry Editor incorrectly can cause serious problems that may require you to reinstall your operating system. Citrix cannot guarantee that problems resulting from the incorrect use of Registry Editor can be solved. Use Registry Editor at your own risk. Be sure to back up the registry before you edit it.

32-bit Windows systems

HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionImage File Execution OptionsImaSrv.exe

x64 Windows systems

HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftWindows NTCurrentVersionImage File Execution OptionsImaSrv.exe

You need to create two new REG_DWORD values under:

32-bit Windows systems

HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionImage File Execution Options<processname>

x64 Windows systems

HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftWindows NTCurrentVersionImage File Execution Options<processname>

as follows:

Name: GlobalFlag Type: REG_DWORD Value: 0x02000000

Name: PageHeapFlags Type: REG_DWORD Value: 0x00000003

More Information

If you need full page heap enabled for other applications, replace ImaSrv with your application name. For other native 64-bit applications download and use gflags.exe from 64-bit Debugging Tools:

Debugging Tools for Windows 64-bit version

Read the entire article on the Citrix knowledgebase here.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.