Debugging Dynamic Memory Usage Errors Using NonStop Native Inspect White Paper
heap_check() will perform a sanity check over the memory management internal data structures.
The function heap_check_always()turns on heap checking in the runtime library enabling
checking for every memory-related call into the runtime library (for example a call to malloc()).
This method of doing memory checking is more limited than what is described here. It will not
compute any memory leak information nor are there any checks for improper use of calls to string
functions. Another drawback of using these functions is the need to recompile and relink the
application.
NOTE: On Guardian OS the user may turn on library checking using this unsupported method
without the need to recompile:
ADD DEFINE =_HEAP_CHECK_ALWAYS_,class map,file on
The debugger command, info corruption, is roughly equivalent to the heap_check()function.
NOTE: heap_check()may be invoked using a command line call from within the Native inspect
debugger. This is simply way to do a very basic check of the heap consistency at a specific
execution point.
For more information see the following NonStop documents:
TNS C Library Calls Reference Manual
Guardian Native C Library Calls Reference Manual
Open System Services Library Calls Reference Manual
The Native Inspect Manual is available at the following location:
http://docs.hp.com/en/528122-008/528122-008.pdf
Prerequisites
Following are the prerequisites for debugging memory-related problems in Native Inspect:
• NSK Native Inspect debugger (T1237) H06.15 running on NSK H06.15 or later.
• Native Inspect uses the heap debugging library, zrtcdll , to enable memory-debugging
support. The zrtcdll library is a part of the NonStop Native Inspect product. If the library
is installed in a directory other than the default $SYSTEM.SYSNN versioned subvolume, you
may specify the library location using the LIB option. In this text this subvolume will always
be referred to as SYS00.
• The program must be launched with the user library zrtcdll. (A user library is introduced
on the command line using the liboption. See an example below in the Heap Profiling
section.)
• The user must enable heap checking from within the debugger. (See heap-check on for
more details.)
• The memory-debugging feature is supported only for programs that directly or indirectly call
malloc(), realloc, calloc(), or free() from the standard C library,
$SYSTEM.SYS00.ZCREDLL.
Limitations
The following are some of the limitations in the use of memory leak detection in Native Inspect.
• The memory debugging feature is not available when the application is stopped in a
dynamic-link library (DLL).
• The memory debugging feature is not supported for threaded programs as of H06.15.
• The program can not require a user library (a “user library” is a special library specified in
the lib option). Only one user library is allowed and that is used for the zrtcdll library.
Prerequisites 5










