]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/tools/build/src/engine/boehm_gc/doc/gc.man
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / tools / build / src / engine / boehm_gc / doc / gc.man
CommitLineData
7c673cae
FG
1.TH GC_MALLOC 1L "2 October 2003"
2.SH NAME
3GC_malloc, GC_malloc_atomic, GC_free, GC_realloc, GC_enable_incremental, GC_register_finalizer, GC_malloc_ignore_off_page, GC_malloc_atomic_ignore_off_page, GC_set_warn_proc \- Garbage collecting malloc replacement
4.SH SYNOPSIS
5#include "gc.h"
6.br
7void * GC_malloc(size_t size);
8.br
9void GC_free(void *ptr);
10.br
11void * GC_realloc(void *ptr, size_t size);
12.br
13.sp
14cc ... gc.a
15.LP
16.SH DESCRIPTION
17.I GC_malloc
18and
19.I GC_free
20are plug-in replacements for standard malloc and free. However,
21.I
22GC_malloc
23will attempt to reclaim inaccessible space automatically by invoking a conservative garbage collector at appropriate points. The collector traverses all data structures accessible by following pointers from the machines registers, stack(s), data, and bss segments. Inaccessible structures will be reclaimed. A machine word is considered to be a valid pointer if it is an address inside an object allocated by
24.I
25GC_malloc
26or friends.
27.LP
28In most cases it is preferable to call the macros GC_MALLOC, GC_FREE, etc.
29instead of calling GC_malloc and friends directly. This allows debugging
30versions of the routines to be substituted by defining GC_DEBUG before
31including gc.h.
32.LP
33See the documentation in the include file gc_cpp.h for an alternate, C++ specific interface to the garbage collector.
34.LP
35Unlike the standard implementations of malloc,
36.I
37GC_malloc
38clears the newly allocated storage.
39.I
40GC_malloc_atomic
41does not. Furthermore, it informs the collector that the resulting object will never contain any pointers, and should therefore not be scanned by the collector.
42.LP
43.I
44GC_free
45can be used to deallocate objects, but its use is optional, and generally discouraged.
46.I
47GC_realloc
48has the standard realloc semantics. It preserves pointer-free-ness.
49.I
50GC_register_finalizer
51allows for registration of functions that are invoked when an object becomes inaccessible.
52.LP
53The garbage collector tries to avoid allocating memory at locations that already appear to be referenced before allocation. (Such apparent ``pointers'' are usually large integers and the like that just happen to look like an address.) This may make it hard to allocate very large objects. An attempt to do so may generate a warning.
54.LP
55.I
56GC_malloc_ignore_off_page
57and
58.I
59GC_malloc_atomic_ignore_off_page
60inform the collector that the client code will always maintain a pointer to near the beginning of the object (within the first 512 bytes), and that pointers beyond that can be ignored by the collector. This makes it much easier for the collector to place large objects. These are recommended for large object allocation. (Objects expected to be larger than about 100KBytes should be allocated this way.)
61.LP
62It is also possible to use the collector to find storage leaks in programs destined to be run with standard malloc/free. The collector can be compiled for thread-safe operation. Unlike standard malloc, it is safe to call malloc after a previous malloc call was interrupted by a signal, provided the original malloc call is not resumed.
63.LP
64The collector may, on rare occasion produce warning messages. On UNIX machines these appear on stderr. Warning messages can be filtered, redirected, or ignored with
65.I
66GC_set_warn_proc
67This is recommended for production code. See gc.h for details.
68.LP
69Fully portable code should call
70.I
71GC_INIT
72from the main program before making any other GC calls.
73On most platforms this does nothing and the collector is initialized on first use.
74On a few platforms explicit initialization is necessary. And it can never hurt.
75.LP
76Debugging versions of many of the above routines are provided as macros. Their names are identical to the above, but consist of all capital letters. If GC_DEBUG is defined before gc.h is included, these routines do additional checking, and allow the leak detecting version of the collector to produce slightly more useful output. Without GC_DEBUG defined, they behave exactly like the lower-case versions.
77.LP
78On some machines, collection will be performed incrementally after a call to
79.I
80GC_enable_incremental.
81This may temporarily write protect pages in the heap. See the README file for more information on how this interacts with system calls that write to the heap.
82.LP
83Other facilities not discussed here include limited facilities to support incremental collection on machines without appropriate VM support, provisions for providing more explicit object layout information to the garbage collector, more direct support for ``weak'' pointers, support for ``abortable'' garbage collections during idle time, etc.
84.LP
85.SH "SEE ALSO"
86The README and gc.h files in the distribution. More detailed definitions of the functions exported by the collector are given there. (The above list is not complete.)
87.LP
88The web site at http://www.hpl.hp.com/personal/Hans_Boehm/gc .
89.LP
90Boehm, H., and M. Weiser, "Garbage Collection in an Uncooperative Environment",
91\fISoftware Practice & Experience\fP, September 1988, pp. 807-820.
92.LP
93The malloc(3) man page.
94.LP
95.SH AUTHOR
96Hans-J. Boehm (Hans.Boehm@hp.com).
97Some of the code was written by others, most notably Alan Demers.