1 .\" Copyright (c) 2012 by Michael Kerrisk <mtk.manpages@gmail.com>
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .TH malloc_trim 3 (date) "Linux man-pages (unreleased)"
7 malloc_trim \- release free memory from the heap
10 .RI ( libc ", " \-lc )
13 .B #include <malloc.h>
15 .BI "int malloc_trim(size_t " pad );
20 function attempts to release free memory from the heap
25 with suitable arguments).
29 argument specifies the amount of free space to leave untrimmed
30 at the top of the heap.
31 If this argument is 0, only the minimum amount of memory is maintained
32 at the top of the heap (i.e., one page or less).
33 A nonzero argument can be used to maintain some trailing space
34 at the top of the heap in order to allow future allocations
35 to be made without having to extend the heap with
40 function returns 1 if memory was actually released back to the system,
41 or 0 if it was not possible to release any memory.
43 No errors are defined.
45 .\" Available already in glibc 2.0, possibly earlier
47 For an explanation of the terms used in this section, see
55 Interface Attribute Value
58 T} Thread safety MT-Safe
64 This function is a GNU extension.
66 Only the main heap (using
70 argument; thread heaps do not.
72 Since glibc 2.8 this function frees memory in all arenas and in all
73 chunks with whole free pages.
74 .\" See commit 68631c8eb92ff38d9da1ae34f6aa048539b199cc
75 .\" (dated 2007-12-16) which adds iteration over all
76 .\" arenas and frees all pages in chunks which are free.
78 Before glibc 2.8 this function only freed memory at the
79 top of the heap in the main arena.