Format
#include <stdlib.h> /* also in <malloc.h> */ void _dump_allocated(int nbytes);
Language Level: Extension
_dump_allocated prints information to stderr about each memory
block that is currently allocated and was allocated using the
debug memory management functions (_debug_calloc, _debug_malloc,
and so on).
Use nbytes to specify how many bytes of each memory block are to be printed. If nbytes is a:
| Negative value | Prints all bytes of each block. |
| 0 | Prints no bytes. |
| Positive value | Prints the specified number of bytes or the entire block, whichever is smaller. |
Call _dump_allocated at points in your code where you want a report of the currently allocated memory. For example, a good place to call _dump_allocated is a point where most of the memory is already freed and you want to find a memory leak, such as at the end of a program.
_dump_allocated prints the information to stderr, but you can change the destination with the _set_crt_msg_handle function. You can also use _dump_allocated_delta to display information only about the memory that was allocated since the previous call to _dump_allocated or _dump_allocated_delta.
To use _dump_allocated and the debug memory management functions, you must compile with the debug memory (/Tm) compiler option.
Note: The /Tm option maps all calls to memory management functions (including a heap-specific version and a tiled version for OS/2) to their debug counterparts. To prevent a call from being mapped, parenthesize the function name.
A heap-specific version of this function and a tiled version for OS/2, (_udump_allocated and _tdump_allocated) are also available. _dump_allocated always prints information about memory allocated from the default heap.
Return Value
There is no return value.
![]()
Managing Memory
with Multiple Heaps
Memory Management
![]()
_debug_calloc -- Allocate and Initialize
Memory
_debug_free -- Release Memory
_debug_malloc -- Allocate Memory
_debug_realloc -- Reallocate Memory
Block
_dump_allocated_delta -- Get
Information about Allocated Memory
_heap_check -- Validate Default Memory
Heap
_udump_allocated -- Get Information
about Allocated Memory in Heap
<malloc.h>
<stdlib.h>
/Tm compiler option