|
This manual page is part of Xcode Tools version 3.2.2To obtain these tools:
If you are running a version of Xcode Tools other than 3.2.2, view the documentation locally:
Reading manual pagesManual pages are intended as a quick reference for people who already understand a technology.
|
malloc_history(1) BSD General Commands Manual malloc_history(1) NAME malloc_history -- Show the malloc allocations that the process has performed SYNOPSIS malloc_history pid address malloc_history pid -all_by_size malloc_history pid -all_by_count malloc_history pid -all_events DESCRIPTION malloc_history inspects a given process and lists the malloc allocations performed by it. malloc_his-tory malloc_history tory relies on information provided by the standard malloc library when debugging options have been turned on. By specifying an address, malloc_history lists all allocations and deallocations of any malloc block that started at that address, or (starting in Mac OS X 10.6) of any malloc block that contained that address. For each allocation, a stack trace describing who called malloc or free is listed. If you do only wish to see events for malloc blocks that started at the specified address, you can grep the out-put output put for that address. Alternatively, the -all_by_size and -all_by_count options list all allocations. Frequent allocations from the same point in the program (that is, the same call stack) are grouped together, and output pre-sented presented sented either from largest allocations to smallest, or most allocations to least. The -all_events option lists all allocation and free events, for all addresses. This output can be voluminous. All modes require the standard malloc library's debugging facility to be turned on. To do this, set either the MallocStackLogging or MallocStackLoggingNoCompact environment variable to 1 in the shell that will run the program. If MallocStackLogging is used, then when recording events, if an allocation event for an address is immediately followed by a free event for the same address, both events are removed from the event log. If MallocStackLoggingNoCompact is used, then all such immediate alloca-tion/free allocation/free tion/free pairs are kept in the event log, which can be useful when examining all events for a specific address, or when using the -all_events option. If both MallocStackLogging and MallocStackLoggingNoCompact are set, then MallocStackLogging takes precedence and MallocStackLoggingNoCompact is ignored. malloc_history is particularly useful for tracking down memory smashers. Run the program to be inspected with MallocStackLogging or MallocStackLoggingNoCompact defined. Also set the environment variable MallocScribble; this causes the malloc library to overwrite freed memory with a well-known value (0x55), and occasionally checks freed malloc blocks to make sure the memory has not been over-written overwritten written since it was cleared. When malloc detects the memory has been written, it will print out a warning that the buffer was modified after being freed. You can then use malloc_history 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), DevToolsSecurity(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 malloc_history. 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. BSD Oct. 4, 2008 BSD |
The way to report a problem with this manual page depends on the type of problem: