You can adjust some parameters for dynamic memory allocation with the
mallopt function. This function is the general SVID/XPG
interface, defined in malloc.h.
mallopt, the param argument specifies the parameter to be set, and value the new value to be set. Possible choices for param, as defined in malloc.h, are:
- This is the minimum size (in bytes) of the top-most, releasable chunk that will cause
sbrkto be called with a negative argument in order to return memory to the system.
- This parameter determines the amount of extra memory to obtain from the system when a call to
sbrkis required. It also specifies the number of bytes to retain when shrinking the heap by calling
sbrkwith a negative argument. This provides the necessary hysteresis in heap size such that excessive amounts of system calls can be avoided.
- All chunks larger than this value are allocated outside the normal heap, using the
mmapsystem call. This way it is guaranteed that the memory for these chunks can be returned to the system on
free. Note that requests smaller than this threshold might still be allocated via
- The maximum number of chunks to allocate with
mmap. Setting this to zero disables all use of
- If non-zero, memory blocks are filled with values depending on some low order bits of this parameter when they are allocated (except when allocated by
calloc) and freed. This can be used to debug the use of uninitialized or freed heap memory. Note that this option does not guarantee that the freed block will have any specific values. It only guarantees that the content the block had before it was freed will be overwritten.