Tuesday, August 17, 2010

Track memory leak using Purify

Tracking memory leak from a child process of a window service requires a little bit setup upfront.

I worked on a defect regarding to memory leak from a child process of a window service recently. I used the following steps to allow Purify to track the memory usage in the child process.

1. Add the Purify product directory and the Purify cache directory to the system Path environment variable. For a system service, it is important to add these directories to the system Path environment variable, not just the user Path environment variable.

2. Instrument both window service and child process executable from the command line.
purify /run=no /replace=yes win_service.exe
purify /run=no /replace=yes child_process.exe

3. Add ServicesPipeTimeout registry entry to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control with a big DWORD value, i.e. 180000 (3 minutes) to allow instrumented service to start from the Service Control Panel.

4. Select the option Allow Service to Interact with Desktop for the service so that Purify is visible while the service is running.

5. Change the service startup type to Manual.

6. Launch the instrumented service application from the Service Control Panel. When the service runs, it brings up Purify so I could see data for both the service and child process displayed in separate error views.

0 comments:

Post a Comment