OSDN Git Service

6388a71334f4c5f3b17a2538f12604195998d7c9
[linuxjm/LDP_man-pages.git] / original / man3 / malloc_trim.3
1 '\" t
2 .\" Copyright (c) 2012 by Michael Kerrisk <mtk.manpages@gmail.com>
3 .\"
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\"
24 .TH MALLOC_TRIM 3  2012-03-29 "Linux" "Linux Programmer's Manual"
25 .SH NAME
26 malloc_trim \- release free memory from the top of the heap
27 .SH SYNOPSIS
28 .B #include <malloc.h>
29
30 .BI "void malloc_trim(size_t "  pad );
31 .SH DESCRIPTION
32 The
33 .BR malloc_trim ()
34 function attempts to release free memory at the top of the heap
35 (by calling
36 .BR sbrk (2)
37 with a suitable argument).
38
39 The
40 .I pad
41 argument specifies the amount of free space to leave untrimmed
42 at the top of the heap.
43 If this argument is 0, only the minimum amount of memory is maintained
44 at the top of the heap (i.e., one page or less).
45 A nonzero argument can be used to maintain some trailing space
46 at the top of the heap in order to allow future allocations
47 to be made without having to extend the heap with
48 .BR sbrk (2).
49 .SH RETURN VALUE
50 The
51 .BR malloc_trim ()
52 function returns 1 if memory was actually released back to the system,
53 or 0 if it was not possible to release any memory.
54 .SH ERRORS
55 No errors are defined.
56 .\" .SH VERSIONS
57 .\" Available already in glibc 2.0, possibly earlier
58 .SH CONFORMING TO
59 This function is a GNU extension.
60 .SH NOTES
61 This function is automatically called by
62 .BR free (3)
63 in certain circumstances; see the discussion of
64 .B M_TOP_PAD
65 and
66 .B M_TRIM_THRESHOLD
67 in
68 .BR mallopt (3).
69
70 This function cannot release free memory located at places
71 other than the top of the heap.
72 .SH NOTES
73 This function only releases memory in the main arena.
74 .\" malloc/malloc.c::mTRIm():
75 .\"     return result | (av == &main_arena ? sYSTRIm (pad, av) : 0);
76 .SH SEE ALSO
77 .BR sbrk (2),
78 .BR malloc (3),
79 .BR mallopt (3)