Debugging Memory Problems with MemoryScape : Chapter 4 Creating Programs for Memory Debugging : Using env to Insert the Agent
Using env to Insert the Agent
When MemoryScape attaches to a process that is already running, the agent must already be associated with it. You can do this in two ways:
*Manually link the agent as described in previous sections.
*Start the program using env (see man env on your system). This pushes the agent into your program.
* 
Preloading cannot be used with Cray or Blue Gene/L platforms.For information on preloading with Blue Gene/P and Blue Gene/Q, see the earlier section Linking Your Application with the Agent.
The variables required by each platform are shown in the following table. The placeholder <hia_dir> represents the directory in which the agent is found. See the previous section for how to determine this location.
Platform
Variable
Apple Mac OS X
Snow Leopard and later
Pre Snow Leopard
 
DYLD_INSERT_LIBRARIES=<hia_dir>/libtvheap.dylib
 
DYLD_INSERT_LIBRARIES=<hia_dir>/libtvheap_darwin.dylib:<hia_dir>/libtvheap.dylib
(all one line)
IBM AIX
MALLOCTYPE=user:tvheap_mr.a
If you are already using MALLOCTYPE for another purpose, reassign its value to the variable TVHEAP_MALLOCTYPE and assign MALLOCTYPE as above; when the agent starts it will correctly pass on the options.
Linux and HP-UX
32-bit
64-bit
 
LD_PRELOAD=<hia_dir>/libtvheap.so
LD_PRELOAD=<hia_dir>/libtvheap_64.so
 
Sun
32-bit generic
32-bit specific
64-bit generic
64-bit specific
 
 
LD_PRELOAD=<hia_dir>/libtvheap.so
LD_PRELOAD_32=<hia_dir>/libtvheap.so
LD_PRELOAD=<hia_dir>/libtvheap_64.so
LD_PRELOAD_64=<hia_dir>/libtvheap.so
If the agent is the only library you are preloading, use the generic variable. Otherwise, use whichever variable was used for the other preloaded libraries.
Other related topics are:
*Linking Your Application with the Agent”
*Installing tvheap_mr.a on AIX”