Determining Memory Leaks in Citrix SDK Functions
To determine whether or not a process is experiencing memory leaks, use Windows Performance Monitor (Perfmon.exe) and monitor Private Bytes under the Process category for your application. “Private Bytes” is the total memory that the process has allocated but is not sharing with other processes.
Note This is different from Virtual Bytes.
“Virtual Bytes” is the current size of the virtual address space that the process uses. An application can leak virtual memory, but may not see a difference in the private bytes that are allocated. If you do not see memory increase when you monitor private bytes but you suspect that you are still running out of memory, monitor virtual bytes to see if you are using up virtual memory.
If you suspect a function that belongs to any Citrix SDK is leaking memory, a good approach is to include the code in an infinite loop and monitor the number of bytes.
When the leak is identified, you can use the tool Umdh.exe (User Mode Dump Heap) to identify how much memory is leaking and whether the Citrix module is actually the one that is leaking.
View the following article for a complete description of this utility: 268343
Umdh.exe is a utility that dumps information about the heap allocations of a process. This information includes the callstack for each allocation, the number of allocations that are made through that callstack, and the number of bytes that are consumed through that callstack.
To use this tool, you need to perform the following steps:
1. Install the UMDH utility.
2. Set the System PATH environment variable to include the folder where you installed UMDH.
3. Set the _NT_SYMBOL_PATH environment variable to the Microsoft symbol server path so that UMDH can locate debug symbol files
4. Enable stack trace acquisition for the application that you want to test. By default, this feature is not enabled. The command to enable this feature is as follows:
gflags -i testsdk.exe +ust
Note: This assumes Testsdk.exe is a project that uses Citrix SDK functions.
Then run:
umdh -p:PID_of_testsdk -f:testsdk.log
5. Use Umdh.exe to compare UMDH logs.
While the Umdh log file contains valuable information about the current state of the heaps for a process, if you are concerned with finding a memory leak, it may be more valuable to compare the output of the two log files to determine what callstack has grown the most. The Umdh.exe utility helps compare two Umdh log files to provide an analysis of the difference between them. After you capture two log files at different intervals, use the following command:
UMDH testsdk1.log testsdk2.log > cmp12.txt