]>
Commit | Line | Data |
---|---|---|
a15b0e60 MK |
1 | '\" t |
2 | .\" Copyright (c) 2012 by Michael Kerrisk <mtk.manpages@gmail.com> | |
3 | .\" | |
93015253 | 4 | .\" %%%LICENSE_START(VERBATIM) |
a15b0e60 MK |
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. | |
8 | .\" | |
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. | |
13 | .\" | |
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 | |
20 | .\" professionally. | |
21 | .\" | |
22 | .\" Formatted or processed versions of this manual, if unaccompanied by | |
23 | .\" the source, must acknowledge the copyright and authors of this work. | |
4b72fb64 | 24 | .\" %%%LICENSE_END |
a15b0e60 | 25 | .\" |
4b8c67d9 | 26 | .TH MALLOC_TRIM 3 2017-09-15 "Linux" "Linux Programmer's Manual" |
a15b0e60 MK |
27 | .SH NAME |
28 | malloc_trim \- release free memory from the top of the heap | |
29 | .SH SYNOPSIS | |
30 | .B #include <malloc.h> | |
dbfe9c70 | 31 | .PP |
7b7fbe78 | 32 | .BI "int malloc_trim(size_t " pad ); |
a15b0e60 MK |
33 | .SH DESCRIPTION |
34 | The | |
35 | .BR malloc_trim () | |
36 | function attempts to release free memory at the top of the heap | |
37 | (by calling | |
38 | .BR sbrk (2) | |
39 | with a suitable argument). | |
847e0d88 | 40 | .PP |
a15b0e60 MK |
41 | The |
42 | .I pad | |
43 | argument specifies the amount of free space to leave untrimmed | |
44 | at the top of the heap. | |
45 | If this argument is 0, only the minimum amount of memory is maintained | |
46 | at the top of the heap (i.e., one page or less). | |
47 | A nonzero argument can be used to maintain some trailing space | |
48 | at the top of the heap in order to allow future allocations | |
49 | to be made without having to extend the heap with | |
50 | .BR sbrk (2). | |
51 | .SH RETURN VALUE | |
52 | The | |
53 | .BR malloc_trim () | |
54 | function returns 1 if memory was actually released back to the system, | |
55 | or 0 if it was not possible to release any memory. | |
56 | .SH ERRORS | |
57 | No errors are defined. | |
58 | .\" .SH VERSIONS | |
59 | .\" Available already in glibc 2.0, possibly earlier | |
0cc0b5e4 ZL |
60 | .SH ATTRIBUTES |
61 | For an explanation of the terms used in this section, see | |
62 | .BR attributes (7). | |
63 | .TS | |
64 | allbox; | |
65 | lb lb lb | |
66 | l l l. | |
67 | Interface Attribute Value | |
68 | T{ | |
69 | .BR malloc_trim () | |
70 | T} Thread safety MT-Safe | |
71 | .TE | |
847e0d88 | 72 | .sp 1 |
a15b0e60 MK |
73 | .SH CONFORMING TO |
74 | This function is a GNU extension. | |
75 | .SH NOTES | |
76 | This function is automatically called by | |
77 | .BR free (3) | |
78 | in certain circumstances; see the discussion of | |
79 | .B M_TOP_PAD | |
80 | and | |
81 | .B M_TRIM_THRESHOLD | |
82 | in | |
83 | .BR mallopt (3). | |
847e0d88 | 84 | .PP |
a15b0e60 MK |
85 | This function cannot release free memory located at places |
86 | other than the top of the heap. | |
847e0d88 | 87 | .PP |
ec18b513 | 88 | This function releases only memory in the main arena. |
a15b0e60 MK |
89 | .\" malloc/malloc.c::mTRIm(): |
90 | .\" return result | (av == &main_arena ? sYSTRIm (pad, av) : 0); | |
91 | .SH SEE ALSO | |
92 | .BR sbrk (2), | |
93 | .BR malloc (3), | |
94 | .BR mallopt (3) |