heap(1) BSD General Commands Manual heap(1)
NAME
heap -- List all the malloc-allocated buffers in the process's heap
SYNOPSIS
heap [-guessNonObjects] pid | partial-executable-name
DESCRIPTION
heap lists the objects currently allocated on the heap of the specified process, as well as summary
data. Objects are categorized by class name, type (Objective-C, C++, or CFType), and binary image.
C++ objects are identified by the vtable referenced from the start of the object, so with multiple
inheritance this may not give the precise class of the object.
The binary image identified for a class is the image which implements the class, not necessarily the
binary image which caused the objects to be allocated at runtime, or which "owns" those objects.
heap requires one parameter -- either a process ID or a full or partial executable name.
The -guessNonObjects option causes heap to look through the memory contents of each Objective-C object
to find pointers to malloc'ed blocks (non-objects), such as the variable array hanging from an NSArray.
These referenced blocks of memory are identified as their offset from the start of the object (say
"NSCFArray[12]"). The count, number of bytes, and average size of memory blocks referenced from each
different object offset location are listed in the output.
SEE ALSO
malloc(3), leaks(1), malloc_history(1), vmmap(1)
The developer tools for the system also include a graphical application, /Developer/Applica-tions/Instruments.app, /Developer/Applications/Instruments.app,
tions/Instruments.app, that provides instruments that give information similar to that provided by
heap. The ObjectAlloc instrument graphically displays dynamic, real-time information about the object
and memory use in an application, including backtraces of where the allocations occured. The Leaks
instrument in performs memory leak analysis. To use these instruments, the target application must be
launched from Instruments.app, whereas heap can examine existing processes. heap also has the advan-tage advantage
tage that the data can be immediately parsed by text-based tools, and impacts the system less because
it is not a full graphical application.
BSD March 15, 2007 BSD
|