home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
sa104os2.zip
/
SATHR104.ZIP
/
SATHER
/
DOC
/
MAN
/
CAT1
/
GC.1
< prev
Wrap
Text File
|
1994-11-18
|
4KB
|
133 lines
GC_MALLOC(1L) Misc. Reference Manual Pages GC_MALLOC(1L)
NAME
GC_malloc, GC_malloc_atomic, GC_free, GC_realloc,
GC_enable_incremental, GC_register_finalizer - Garbage col-
lecting malloc replacement
SYNOPSIS
#include "gc.h"
# define malloc(n) GC_malloc(n)
cc ... gc.a
DESCRIPTION
_G_C__m_a_l_l_o_c and _G_C__f_r_e_e are plug-in replacements for standard
malloc and free. However, _G_C__m_a_l_l_o_c will attempt to reclaim
inaccessible space automaticaly 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 _G_C__m_a_l_l_o_c or friends.
Unlike the standard implementations of malloc, _G_C__m_a_l_l_o_c
clears the newly allocated storage. _G_C__m_a_l_l_o_c__a_t_o_m_i_c does
not. Furthermore, it informs the collector that the result-
ing object will never contain any pointers, and should
therefore not be scanned by the collector. _G_C__f_r_e_e can be
used to deallocate objects, but its use is optional, and
discouraged. _G_C__r_e_a_l_l_o_c has the standard realloc semantics.
It preserves pointer-free-ness. _G_C__r_e_g_i_s_t_e_r__f_i_n_a_l_i_z_e_r
allows for registration of functions that are invoked when
an object becomes inaccessible.
It 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 mal-
loc after a previous malloc call was interrupted by a sig-
nal, provided the original malloc call is not resumed.
Debugging versions of many of the above routines are pro-
vided 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 check-
ing, 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.
On some machines, collection will be performed incrementally
after a call to _G_C__e_n_a_b_l_e__i_n_c_r_e_m_e_n_t_a_l. This may temporarily
write protect pages in the heap. See the README file for
more information on how this interacts with system calls
Sun Microsystems Last change: 20 April 1994 1
GC_MALLOC(1L) Misc. Reference Manual Pages GC_MALLOC(1L)
that write to the heap.
Other facilities not discussed here include a C++ interface,
limited facilities to support incremental collection on
machines without appropriate VM support, provisions for pro-
viding more explicit object layout information to the gar-
bage collector, more direct support for ``weak'' pointers,
etc.
SEE ALSO
The README and gc.h files in the distribution. More
detailed definitions of the functions exported by the col-
lector are given there. (The above list is not complete.)
Boehm, H., and M. Weiser, "Garbage Collection in an
Uncooperative Environment", _S_o_f_t_w_a_r_e _P_r_a_c_t_i_c_e & _E_x_p_e_r_i_e_n_c_e,
September 1988, pp. 807-820.
The malloc(3) man page.
AUTHOR
Hans-J. Boehm (boehm@parc.xerox.com). Some of the code was
written by others, most notably Alan Demers.
Sun Microsystems Last change: 20 April 1994 2