Debugging Dynamic Memory Usage Errors Using NonStop Native Inspect White Paper
• Memory leak reports etc. can not be generated from a process which has been suspended at
stop or abend.
• The memory debugging feature can not be used with applications that redefine or override
the default system-supplied versions of the standard library routines (under zcredll, and
zcrtldll), such as abort(), strcat(), and dlclose(). If there are doubts about the
applications’ use of memory functions, one can use the enoft utility. enoft may be
used to determine if the application or the dependent libraries in the application redefine or
substitute the standard library routines. For more information on the dependent standard library
routines, see the Native Inspect Manual.
• Memory leak detection reports are not available when the application is suspended at stop
or in an abend state.
Memory-Related Errors
This section discusses the following memory-related errors that can occur in an application.
• Heap corruption
• Memory leaks
• Access errors
This section provides the background for understanding how memory corruptions and leaks happen
and how software in the debugger is able to detect them.
Heap Corruption
A heap corruption occurs when an application erroneously overwrites some of the data in the
heap. Heap corruption can result in data corruption, memory corruption, or both.
NOTE: In this section memory corruption refers to any corruption of memory used by the memory
management system itself as opposed to heap memory used for the application data.
When an application inadvertently uses the erroneously overwritten data in the heap, it results in
data corruption in the application. Data corruption can lead to unpredictable program behavior.
The data corruption in the heap can lead to memory corruption if the corrupted data in the heap
is used by memory management functions in the application to allocate, access, or deallocate
memory blocks. In other words, memory corruption occurs when the corrupted datum in the heap
is accessed as a pointer. Memory corruptions compromise the data integrity of the application
and can result in segmentation violations if the erroneously allocated or accessed memory blocks
are out of the bounds of the virtual memory of the application.
Causes for Heap Corruption
Following are some of the typical causes for heap corruption:
Double-Free
A double-free error occurs when a program attempts to free a memory block that is already freed.
(“Example 6” (page 19) illustrates how Native Inspect detects double-frees.)
Freeing Unallocated/Uninitialized Memory
Heap corruption occurs when a program tries to free memory that is not allocated to the program.
Such instances include freeing uninitialized pointers where the pointer addresses memory outside
the allocated memory. (“Example 7” (page 20) illustrates how Native Inspect detects such errors.)
Memory Leaks
A memory leak occurs when an application fails to free allocated memory. As a result, the kernel
frees the memory that is allocated by a process only when the process terminates. If the program
6










