2 .\" Copyright (c) 2012 by Michael Kerrisk <mtk.manpages@gmail.com>
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein. The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
26 .TH MALLOC_TRIM 3 2019-05-09 "Linux" "Linux Programmer's Manual"
28 malloc_trim \- release free memory from the heap
30 .B #include <malloc.h>
32 .BI "int malloc_trim(size_t " pad );
36 function attempts to release free memory from the heap
41 with suitable arguments).
45 argument specifies the amount of free space to leave untrimmed
46 at the top of the heap.
47 If this argument is 0, only the minimum amount of memory is maintained
48 at the top of the heap (i.e., one page or less).
49 A nonzero argument can be used to maintain some trailing space
50 at the top of the heap in order to allow future allocations
51 to be made without having to extend the heap with
56 function returns 1 if memory was actually released back to the system,
57 or 0 if it was not possible to release any memory.
59 No errors are defined.
61 .\" Available already in glibc 2.0, possibly earlier
63 For an explanation of the terms used in this section, see
69 Interface Attribute Value
72 T} Thread safety MT-Safe
76 This function is a GNU extension.
78 This function is automatically called by
80 in certain circumstances; see the discussion of
87 Only the main heap (using
91 argument; thread heaps do not.
93 Since glibc 2.8 this function frees memory in all arenas and in all
94 chunks with whole free pages.
95 .\" See commit 68631c8eb92ff38d9da1ae34f6aa048539b199cc
96 .\" (dated 2007-12-16) which adds iteration over all
97 .\" arenas and frees all pages in chunks which are free.
99 Before glibc 2.8 this function only freed memory at the
100 top of the heap in the main arena.