1MALLOC_TRIM(3) Linux Programmer's Manual MALLOC_TRIM(3)
2
3
4
6 malloc_trim - release free memory from the top of the heap
7
9 #include <malloc.h>
10
11 void malloc_trim(size_t pad);
12
14 The malloc_trim() function attempts to release free memory at the top
15 of the heap (by calling sbrk(2) with a suitable argument).
16
17 The pad argument specifies the amount of free space to leave untrimmed
18 at the top of the heap. If this argument is 0, only the minimum amount
19 of memory is maintained at the top of the heap (i.e., one page or
20 less). A nonzero argument can be used to maintain some trailing space
21 at the top of the heap in order to allow future allocations to be made
22 without having to extend the heap with sbrk(2).
23
25 The malloc_trim() function returns 1 if memory was actually released
26 back to the system, or 0 if it was not possible to release any memory.
27
29 No errors are defined.
30
32 This function is a GNU extension.
33
35 This function is automatically called by free(3) in certain circum‐
36 stances; see the discussion of M_TOP_PAD and M_TRIM_THRESHOLD in mal‐
37 lopt(3).
38
39 This function cannot release free memory located at places other than
40 the top of the heap.
41
42 This function releases only memory in the main arena.
43
45 sbrk(2), malloc(3), mallopt(3)
46
48 This page is part of release 3.53 of the Linux man-pages project. A
49 description of the project, and information about reporting bugs, can
50 be found at http://www.kernel.org/doc/man-pages/.
51
52
53
54Linux 2012-03-29 MALLOC_TRIM(3)