MALLOC.CONF(5) BSD File Formats Manual MALLOC.CONF(5)
malloc.conf -- options for the memory allocator
The memory allocator functions of the malloc(3) family first look for a
symbolic link called /etc/malloc.conf and next check the environment for
a variable called MALLOC_OPTIONS and finally for the global variable
malloc_options and scan them for flags in that order. Flags are single
letters, uppercase means on, lowercase means off.
A ``Abort''. malloc(3) will coredump the process, rather than tol-
erate internal inconsistencies or incorrect usage. This is the
default and a very handy debugging aid, since the core file rep-
resents the time of failure, rather than when the bogus pointer
D ``Dump''. malloc(3) will dump statistics to the file
./malloc.out, if it already exists, at exit. This option
requires the library to have been compiled with -DMALLOC_STATS in
order to have any effect.
F ``Freeguard''. Enable use after free detection. Unused pages on
the freelist are read and write protected to cause a segmentation
fault upon access. This will also switch off the delayed freeing
of chunks, reducing random behaviour but detecting double free(3)
calls as early as possible. This option is intended for debug-
ging rather than improved security (use the U option for secu-
G ``Guard''. Enable guard pages. Each page size or larger alloca-
tion is followed by a guard page that will cause a segmentation
fault upon any access.
H ``Hint''. Pass a hint to the kernel about pages we don't use.
If the machine is paging a lot this may help a bit.
J ``Junk''. Fill some junk into the area allocated. Currently
junk is bytes of 0xd0 when allocating; this is pronounced
``Duh''. :-) Freed chunks are filled with 0xdf.
j ``Don't Junk''. By default, small chunks are always junked, and
the first part of pages is junked after free. This option
ensures that no junking is performed.
P ``Move allocations within a page.'' Allocations larger than half
a page but smaller than a page are aligned to the end of a page
to catch buffer overruns in more cases. This is the default.
R ``realloc''. Always reallocate when realloc(3) is called, even
if the initial allocation was big enough. This can substantially
aid in compacting memory.
S Enable all options suitable for security auditing.
U ``Free unmap''. Enable use after free protection for larger
allocations. Unused pages on the freelist are read and write
protected to cause a segmentation fault upon access.
X ``xmalloc''. Rather than return failure, abort(3) the program
with a diagnostic message on stderr. It is the intention that
this option be set at compile time by including in the source:
extern char *malloc_options;
malloc_options = "X";
Note that this will cause code that is supposed to handle out-of-
memory conditions gracefully to abort instead.
<< ``Half the cache size''. Decrease the size of the free page
cache by a factor of two.
>> ``Double the cache size''. Increase the size of the free page
cache by a factor of two.
The flags are mostly for testing and debugging. If a program changes
behavior if any of these options (except X) are used, it is buggy.
The default number of free pages cached is 64.
MALLOC_OPTIONS string of option flags
/etc/malloc.conf symbolic link to filename containing option flags
Set a systemwide reduction of the cache to a quarter of the default size
and use guard pages:
# ln -s 'G<<' /etc/malloc.conf
BSD May 30, 2017 BSD