Sun Studio 12 Update 1: Performance Analyzer

Heap Tracing (Memory Allocation) Data

Calls to memory allocation and deallocation functions that are not properly managed can be a source of inefficient data usage and can result in poor program performance. In heap tracing, the Collector traces memory allocation and deallocation requests by interposing on the C standard library memory allocation functions malloc, realloc, valloc, and memalign and the deallocation function free. Calls to mmap are treated as memory allocations, which allows heap tracing events for Java memory allocations to be recorded. The Fortran functions allocate and deallocate call the C standard library functions, so these routines are traced indirectly.

Heap profiling for Java programs is not supported.

Heap tracing data is converted into the following metrics.

Table 2–3 Memory Allocation (Heap Tracing) Metrics

Metric 

Definition 

Allocations 

The number of calls to the memory allocation functions. 

Bytes allocated 

The sum of the number of bytes allocated in each call to the memory allocation functions. 

Leaks 

The number of calls to the memory allocation functions that did not have a corresponding call to a deallocation function. 

Bytes leaked 

The number of bytes that were allocated but not deallocated. 

Collecting heap tracing data can help you identify memory leaks in your program or locate places where there is inefficient allocation of memory.

Another definition of memory leaks that is commonly used, such as in the dbx debugging tool, says a memory leak is a dynamically-allocated block of memory that has no pointers pointing to it anywhere in the data space of the program. The definition of leaks used here includes this alternative definition, but also includes memory for which pointers do exist.