2 .\" Copyright (c) 2012 by Michael Kerrisk <mtk.manpages@gmail.com>
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .TH malloc_trim 3 (date) "Linux man-pages (unreleased)"
8 malloc_trim \- release free memory from the heap
11 .RI ( libc ", " \-lc )
14 .B #include <malloc.h>
16 .BI "int malloc_trim(size_t " pad );
21 function attempts to release free memory from the heap
26 with suitable arguments).
30 argument specifies the amount of free space to leave untrimmed
31 at the top of the heap.
32 If this argument is 0, only the minimum amount of memory is maintained
33 at the top of the heap (i.e., one page or less).
34 A nonzero argument can be used to maintain some trailing space
35 at the top of the heap in order to allow future allocations
36 to be made without having to extend the heap with
41 function returns 1 if memory was actually released back to the system,
42 or 0 if it was not possible to release any memory.
44 No errors are defined.
46 For an explanation of the terms used in this section, see
52 Interface Attribute Value
57 T} Thread safety MT-Safe
64 Only the main heap (using
68 argument; thread heaps do not.
70 Since glibc 2.8 this function frees memory in all arenas and in all
71 chunks with whole free pages.
72 .\" See commit 68631c8eb92ff38d9da1ae34f6aa048539b199cc
73 .\" (dated 2007-12-16) which adds iteration over all
74 .\" arenas and frees all pages in chunks which are free.
76 Before glibc 2.8 this function only freed memory at the
77 top of the heap in the main arena.