Manual Pages for UNIX Darwin command on man malloc_history
MyWebUniversity

Manual Pages for UNIX Darwin command on man malloc_history

mallochistory(1) BSD General Commands Manual mallochistory(1)

NAME

mmaalllloocchhiissttoorryy - Show the malloc allocations that the process has per-

formed

SYNOPSIS

mmaalllloocchhiissttoorryy pid address

mmaalllloocchhiissttoorryy pid -aallllbbyyssiizzee

mmaalllloocchhiissttoorryy pid -aallllbbyyccoouunntt

DESCRIPTION

mmaalllloocchhiissttoorryy inspects a given process and lists the malloc allocations performed by it. mallochistory relies on information provided by the standard malloc library when debugging options have been turned on.

By specifying an address, mmaalllloocchhiissttoorryy lists the allocations and deal-

locations that have manipulated a buffer at that address. For each allo-

cation, a stack trace describing who called malloc or free is listed.

Alternatively, the -allbysize and -allbycount options will list all

allocations. Frequent allocations from the same point in the program (that is, the same call stack) are grouped together, and output presented either from largest allocations to smallest, or most allocations to least. All modes require the standard malloc library's debugging facility to be turned on. To do this, set the environment variable MallocStackLogging

to 1 in the shell that will run the program. To be able to examine allo-

cations by address, also set the environment variable MallocStackLogging-

NoCompact to 1. mmaalllloocchhiissttoorryy is particularly useful for tracking down memory smashers.

Run the program to be inspected with MallocStackLogging and MallocStack-

LoggingNoCompact defined. Also set the environment variable MallocScrib-

ble; this causes the malloc library to overwrite freed memory with a

well-known value (0x55), and occasionally checks freed buffers to make

sure the memory has not been overwritten since it was cleared. When mal-

loc detects the memory has been written, it will print out a warning that

the buffer was modified after being freed. You can then use mallochis-

tory to find who allocated and freed memory at that address, and thus deduce what parts of the code might still have a pointer to the freed structure.

SEE ALSO

malloc(3), heap(1), leaks(1), vmmap(1) The developer tools for the system also include a graphical application, /Developer/Applications/Instruments.app, that provides instruments that

give information similar to that provided by mmaalllloocchhiissttoorryy.. The Objec-

tAlloc instrument graphically displays dynamic, real-time information

about the object and memory use in an application, including backtraces of where the allocations occured. BSD March 15, 2007 BSD




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™