HP-UX Reference (11i v2 03/08) - 3 Library Functions A-M (vol 6)

m
malloc(3C) malloc(3C)
mallopt() Provides for control over the allocation algorithm and other options in the
malloc(3C) package. The available values for cmd are:
M_MXFAST Set maxfast to value. The algorithm allocates all blocks below
the size of maxfast in large groups, then doles them out very
quickly. The default value for maxfast is zero.
M_NLBLKS Set numlblks to value. The above mentioned ‘‘large groups’’ each
contain numlblks blocks. numlblks must be greater than 1. The
default value for numlblks is 100.
M_GRAIN Set grain to value. The sizes of all blocks smaller than maxfast
are considered to be rounded up to the nearest multiple of grain.
grain must be greater than zero. The default value of grain is
the smallest number of bytes that can accommodate alignment of
any data type. value is rounded up to a multiple of the default
when grain is set.
M_BLOCK Block all blockable signals in malloc(),
realloc(), cal-
loc(), and free(). This option is provided for those who need
to write signal handlers that allocate memory. When set, the
malloc(3C) routines can be called from within signal handlers
(they become re-entrant). Default action is not to block all block-
able signals.
NOTE: performance of
malloc() will be impacted consider-
ably when the M_BLOCK option is set.
M_UBLOCK Do not block all blockable signals in malloc(), realloc(),
calloc(), and free(). This option cancels signal blocking
initiated by the M_BLOCK option.
M_REL_LAST_FBLK
Enable the feature of release last free block to heap. This option
is provided for 32-bit applications with one arena. Release of last
block happens only when size of the free block is greater than the
threshold.
The threshold value is defined as
2 * (arena expansion
factor) * 4096 bytes. The feature is disabled if the
M_MXFAST value is greater than or equal to threshold value.
Default action is not to release last block.
These values are defined in the
<malloc.h> header file.
mallopt() can be called repeatedly; but once the first small block is allocated,
it is not possible to change the M_MAXFAST, M_NLBLKS, and M_GRAIN values.
mallinfo() Provides instrumentation describing space usage, but cannot be called until the
first small block is allocated. It returns the structure mallinfo:
arena : total space in arena
fsmblks : number of bytes in free small blocks
fordblks : number of bytes in free ordinary blocks
hblks : number of holding blocks
hblkhd : number of bytes in holding block headers
keepcost : cost of enabling keep option
ordblks : number of ordinary blocks
smblks : number of small blocks
uordblks : number of bytes in ordinary blocks in use
usmblks : number of bytes in small blocks in use
The mallinfo structure is defined in the <malloc.h> header file.
Each of the allocation routines returns a pointer to space suitably aligned (after possible pointer coercion)
for storage of any type of object.
memorymap() Displays the contents of the memory allocator for HP-UX 32-bit operating systems
only. A list of addresses and block descriptions is written (using printf())to
standard output. If the value of the show_stats parameter is 1, statistics
HP-UX 11i Version 2: August 2003 2 Hewlett-Packard Company Section 3597