version 1.1, 1999/11/27 10:58:32 |
version 1.1.1.3, 2000/12/01 14:48:27 |
|
|
Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers |
Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers |
Copyright (c) 1991-1996 by Xerox Corporation. All rights reserved. |
Copyright (c) 1991-1996 by Xerox Corporation. All rights reserved. |
Copyright (c) 1996-1998 by Silicon Graphics. All rights reserved. |
Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved. |
|
Copyright (c) 1999 by Hewlett-Packard Company. All rights reserved. |
|
|
THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED |
THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED |
OR IMPLIED. ANY USE IS AT YOUR OWN RISK. |
OR IMPLIED. ANY USE IS AT YOUR OWN RISK. |
Line 11 Permission to modify the code and to distribute modifi |
|
Line 12 Permission to modify the code and to distribute modifi |
|
provided the above notices are retained, and a notice that the code was |
provided the above notices are retained, and a notice that the code was |
modified is included with the above copyright notice. |
modified is included with the above copyright notice. |
|
|
This is version 4.14 of a conservative garbage collector for C and C++. |
This is version 5.3 of a conservative garbage collector for C and C++. |
|
|
You might find a more recent version of this at |
You might find a more recent version of this at |
|
|
http://reality.sgi.com/boehm/gc.html |
http://www.hpl.hp.com/personal/Hans_Boehm/gc |
|
|
HISTORY - |
HISTORY - |
|
|
Early versions of this collector were developed as a part of research |
Early versions of this collector were developed as a part of research |
projects supported in part by the National Science Foundation |
projects supported in part by the National Science Foundation |
and the Defense Advance Research Projects Agency. |
and the Defense Advance Research Projects Agency. |
Much of the code was rewritten by Hans-J. Boehm at Xerox PARC |
Much of the code was rewritten by Hans-J. Boehm (boehm@acm.org) at Xerox PARC, |
and is now maintained by him at SGI (boehm@sgi.com). |
SGI, and HP Labs. |
|
|
Some other contributors: |
Some other contributors: |
|
|
Line 40 Robert Brazile (brazile@diamond.bbn.com) originally su |
|
Line 41 Robert Brazile (brazile@diamond.bbn.com) originally su |
|
Al Dosser (dosser@src.dec.com) and Regis Cridlig (Regis.Cridlig@cl.cam.ac.uk) |
Al Dosser (dosser@src.dec.com) and Regis Cridlig (Regis.Cridlig@cl.cam.ac.uk) |
subsequently provided updates and information on variation between ULTRIX |
subsequently provided updates and information on variation between ULTRIX |
systems. Parag Patel (parag@netcom.com) supplied the A/UX code. |
systems. Parag Patel (parag@netcom.com) supplied the A/UX code. |
Jesper Peterson(jep@mtiame.mtia.oz.au) and |
Jesper Peterson(jep@mtiame.mtia.oz.au), Michel Schinz, and |
Michel Schinz supplied the Amiga port. |
Martin Tauchmann (martintauchmann@bigfoot.com) supplied the Amiga port. |
Thomas Funke (thf@zelator.in-berlin.de(?)) and |
Thomas Funke (thf@zelator.in-berlin.de(?)) and |
Brian D.Carlstrom (bdc@clark.lcs.mit.edu) supplied the NeXT ports. |
Brian D.Carlstrom (bdc@clark.lcs.mit.edu) supplied the NeXT ports. |
Douglas Steel (doug@wg.icl.co.uk) provided ICL DRS6000 code. |
Douglas Steel (doug@wg.icl.co.uk) provided ICL DRS6000 code. |
Line 475 intended to run with malloc/free (e.g. code with extre |
|
Line 476 intended to run with malloc/free (e.g. code with extre |
|
portability constraints). To do so define FIND_LEAK in Makefile |
portability constraints). To do so define FIND_LEAK in Makefile |
This will cause the collector to invoke the report_leak |
This will cause the collector to invoke the report_leak |
routine defined near the top of reclaim.c whenever an inaccessible |
routine defined near the top of reclaim.c whenever an inaccessible |
object is found that has not been explicitly freed. The collector will |
object is found that has not been explicitly freed. Such objects will |
no longer reclaim inaccessible memory; in this form it is purely a |
also be automatically reclaimed. |
debugging tool. |
|
Productive use of this facility normally involves redefining report_leak |
Productive use of this facility normally involves redefining report_leak |
to do something more intelligent. This typically requires annotating |
to do something more intelligent. This typically requires annotating |
objects with additional information (e.g. creation time stack trace) that |
objects with additional information (e.g. creation time stack trace) that |
Line 612 reclaimed. Exclusive-or'ing forward and backward link |
|
Line 612 reclaimed. Exclusive-or'ing forward and backward link |
|
doesn't cut it. |
doesn't cut it. |
Some C optimizers may lose the last undisguised pointer to a memory |
Some C optimizers may lose the last undisguised pointer to a memory |
object as a consequence of clever optimizations. This has almost |
object as a consequence of clever optimizations. This has almost |
never been observed in practice. Send mail to boehm@sgi.com |
never been observed in practice. Send mail to boehm@acm.org |
for suggestions on how to fix your compiler. |
for suggestions on how to fix your compiler. |
This is not a real-time collector. In the standard configuration, |
This is not a real-time collector. In the standard configuration, |
percentage of time required for collection should be constant across |
percentage of time required for collection should be constant across |
Line 621 heap sizes. But collection pauses will increase for l |
|
Line 621 heap sizes. But collection pauses will increase for l |
|
per MB of accessible memory that needs to be scanned. Your mileage |
per MB of accessible memory that needs to be scanned. Your mileage |
may vary.) The incremental/generational collection facility helps, |
may vary.) The incremental/generational collection facility helps, |
but is portable only if "stubborn" allocation is used. |
but is portable only if "stubborn" allocation is used. |
Please address bug reports to boehm@sgi.com. If you are |
Please address bug reports to boehm@acm.org. If you are |
contemplating a major addition, you might also send mail to ask whether |
contemplating a major addition, you might also send mail to ask whether |
it's already been done (or whether we tried and discarded it). |
it's already been done (or whether we tried and discarded it). |
|
|
Line 1451 Since 4.14alpha1 |
|
Line 1451 Since 4.14alpha1 |
|
|
|
Since 4.14alpha2 |
Since 4.14alpha2 |
- changed STACKBOTTOM for DJGPP (Thanks to Salvador Eduardo Tropea). |
- changed STACKBOTTOM for DJGPP (Thanks to Salvador Eduardo Tropea). |
|
|
|
Since 4.14 |
|
- Reworked large block allocator. Now uses multiple doubly linked free |
|
lists to approximate best fit. |
|
- Changed heap expansion heuristic. Entirely free blocks are no longer |
|
counted towards the heap size. This seems to have a major impact on |
|
heap size stability; the old version could expand the heap way too |
|
much in the presence of large block fragmentation. |
|
- added -DGC_ASSERTIONS and some simple assertions inside the collector. |
|
This is mainlyt for collector debugging. |
|
- added -DUSE_MUNMAP to allow the heap to shrink. Suupported on only |
|
a few UNIX-like platforms for now. |
|
- added GC_dump_regions() for debugging of fragmentation issues. |
|
- Changed PowerPC pointer alignment under Linux to 4. (This needs |
|
checking by someone who has one. The suggestions came to me via a |
|
rather circuitous path.) |
|
- Changed the Linux/Alpha port to walk the data segment backwards until |
|
it encounters a SIGSEGV. The old way to find the start of the data |
|
segment broke with a recent release. |
|
- cordxtra.c needed to call GC_REGISTER_FINALIZER instead of |
|
GC_register_finalizer, so that it would continue to work with GC_DEBUG. |
|
- allochblk sometimes cleared the wrong block for debugging purposes |
|
when it dropped blacklisted blocks. This could result in spurious |
|
error reports with GC_DEBUG. |
|
- added MACOS X Server support. (Thanks to Andrew Stone.) |
|
- Changed the Solaris threads code to ignore stack limits > 8 MB with |
|
a warning. Empirically, it is not safe to access arbitrary pages |
|
in such large stacks. And the dirty bit implementation does not |
|
guarantee that none of them will be accessed. |
|
- Integrated Martin Tauchmann's Amiga changes. |
|
- Integrated James Dominy's OpenBSD/SPARC port. |
|
|
|
Since 5.0alpha1 |
|
- Fixed bugs introduced in alpha1 (OpenBSD & large block initialization). |
|
- Added -DKEEP_BACK_PTRS and backptr.h interface. (The implementation |
|
idea came from Al Demers.) |
|
|
|
Since 5.0alpha2 |
|
- Added some highly incomplete code to support a copied young generation. |
|
Comments on nursery.h are appreciated. |
|
- Changed -DFIND_LEAK, -DJAVA_FINALIZATION, and -DFINALIZE_ON_DEMAND, |
|
so the same effect could be obtained with a runtime switch. This is |
|
a step towards standardizing on a single dynamic GC library. |
|
- Significantly changed the way leak detection is handled, as a consequence |
|
of the above. |
|
|
|
Since 5.0 alpha3 |
|
- Added protection fault handling patch for Linux/M68K from Fergus |
|
Henderson and Roman Hodek. |
|
- Removed the tests for SGI_SOURCE in new_gc_alloc.h. This was causing that |
|
interface to fail on nonSGI platforms. |
|
- Changed the Linux stack finding code to use /proc, after changing it |
|
to use HEURISTIC1. (Thanks to David Mossberger for pointing out the |
|
/proc hook.) |
|
- Added HP/UX incremental GC support and HP/UX 11 thread support. |
|
Thread support is currently still flakey. |
|
- Added basic Linux/IA64 support. |
|
- Integrated Anthony Green's PicoJava support. |
|
- Integrated Scott Ananian's StrongARM/NetBSD support. |
|
- Fixed some fairly serious performance bugs in the incremental |
|
collector. These have probably been there essentially forever. |
|
(Mark bits were sometimes set before scanning dirty pages. |
|
The reclaim phase unnecessarily dirtied full small object pages.) |
|
- Changed the reclaim phase to ignore nearly full pages to avoid |
|
touching them. |
|
- Limited GC_black_list_spacing to roughly the heap growth increment. |
|
- Changed full collection triggering heuristic to decrease full GC |
|
frequency by default, but to explicitly trigger full GCs during |
|
heap growth. This doesn't always improve things, but on average it's |
|
probably a win. |
|
- GC_debug_free(0, ...) failed. Thanks to Fergus Henderson for the |
|
bug report and fix. |
|
|
|
Since 5.0 alpha4 |
|
- GC_malloc_explicitly_typed and friends sometimes failed to |
|
initialize first word. |
|
- Added allocation routines and support in the marker for mark descriptors |
|
in a type structure referenced by the first word of an object. This was |
|
introduced to support gcj, but hopefully in a way that makes it |
|
generically useful. |
|
- Added GC_requested_heapsize, and inhibited collections in nonincremental |
|
mode if the actual used heap size is less than what was explicitly |
|
requested. |
|
- The Solaris pthreads version of GC_pthread_create didn't handle a NULL |
|
attribute pointer. Solaris thread support used the wrong default thread |
|
stack size. (Thanks to Melissa O'Neill for the patch.) |
|
- Changed PUSH_CONTENTS macro to no longer modify first parameter. |
|
This usually doesn't matter, but it was certainly an accident waiting |
|
to happen ... |
|
- Added GC_register_finalizer_no_order and friends to gc.h. They're |
|
needed by Java implementations. |
|
- Integrated a fix for a win32 deadlock resulting from clock() calling |
|
malloc. (Thanks to Chris Dodd.) |
|
- Integrated Hiroshi Kawashima's port to Linux/MIPS. This was designed |
|
for a handheld platform, and may or may not be sufficient for other |
|
machines. |
|
- Fixed a va_arg problem with the %c specifier in cordprnt.c. It appears |
|
that this was always broken, but recent versions of gcc are the first to |
|
report the (statically detectable) bug. |
|
- Added an attempt at a more general solution to dlopen races/deadlocks. |
|
GC_dlopen now temporarily disables collection. Still not ideal, but ... |
|
- Added -DUSE_I686_PREFETCH, -DUSE_3DNOW_PREFETCH, and support for IA64 |
|
prefetch instructions. May improve performance measurably, but I'm not |
|
sure the code will run correctly on processors that don't support the |
|
instruction. Won't build except with very recent gcc. |
|
- Added caching for header lookups in the marker. This seems to result |
|
in a barely measurable performance gain. Added support for interleaved |
|
lookups of two pointers, but unconfigured that since the performance |
|
gain is currently near zero, and it adds to code size. |
|
- Changed Linux DATA_START definition to check both data_start and |
|
__data_start, since nothing else seems to be portable. |
|
- Added -DUSE_LD_WRAP to optionally take advantage of the GNU ld function |
|
wrapping mechanism. Probably currently useful only on Linux. |
|
- Moved some variables for the scratch allocator into GC_arrays, on |
|
Martin Hirzel's suggestion. |
|
- Fixed a win32 threads bug that caused the collector to not look for |
|
interior pointers from one of the thread stacks without |
|
ALL_INTERIOR_POINTERS. (Thanks to Jeff Sturm.) |
|
- Added Mingw32 support. (Thanks again to Jeff Sturm for the patch.) |
|
- Changed the alpha port to use the generic register scanning code instead |
|
of alpha_mach_dep.s. Alpha_mach_dep.s doesn't look for pointers in fp |
|
registers, but gcc sometimes spills pointers there. (Thanks to Manuel |
|
Serrano for helping me debug this by email.) Changed the IA64 code to |
|
do something similar for similar reasons. |
|
|
|
Since 5.0alpha6: |
|
- -DREDIRECT_MALLOC was broken in alpha6. Fixed. |
|
- Cleaned up gc_ccp.h slightly, thus also causing the HP C++ compiler to |
|
accept it. |
|
- Removed accidental reference to dbg_mlc.c, which caused dbg_mlc.o to be |
|
linked into every executable. |
|
- Added PREFETCH to bitmap marker. Changed it to use the header cache. |
|
- GC_push_marked sometimes pushed one object too many, resulting in a |
|
segmentation fault in GC_mark_from_mark_stack. This was probably an old |
|
bug. It finally showed up in gctest on win32. |
|
- Gc_priv.h erroneously #defined GC_incremental to be TRUE instead of FALSE |
|
when SMALL_CONFIG was defined. This was no doubt a major performance bug for |
|
the default win32 configuration. |
|
- Removed -DSMALL_CONFIG from NT_MAKEFILE. It seemed like an anchronism now |
|
that the average PC has 64MB or so. |
|
- Integrated Bryce McKinley's patches for linux threads and dynamic loading |
|
from the libgcj tree. Turned on dynamic loading support for Linux/PPC. |
|
- Changed the stack finding code to use environ on HP/UX. (Thanks |
|
to Gustavo Rodriguez-Rivera for the suggestion.) This should probably |
|
be done on other platforms, too. Since I can't test those, that'll |
|
wait until after 5.0. |
|
|
|
Since 5.0alpha7: |
|
- Fixed threadlibs.c for linux threads. -DUSE_LD_WRAP was broken and |
|
-ldl was omitted. Fixed Linux stack finding code to handle |
|
-DUSE_LD_WRAP correctly. |
|
- Added MSWIN32 exception handler around marker, so that the collector |
|
can recover from root segments that are unmapped during the collection. |
|
This caused occasional failures under Windows 98, and may also be |
|
an issue under Windows NT/2000. |
|
|
|
Since 5.0 |
|
- Fixed a gc.h header bug which showed up under Irix. (Thanks to |
|
Dan Sullivan.) |
|
- Fixed a typo in GC_double_descr in typd_mlc.c not getting traced correctly. |
|
This probably could result in objects described by array descriptors not |
|
getting traced correctly. (Thanks to Ben Hutchings for pointing this out.) |
|
- The block nearly full tests in reclaim.c were not correct for 64 bit |
|
environments. This could result in unnecessary heap growth under unlikely |
|
conditions. |
|
- Removed use of CLEAR_DOUBLE from generic reclaim code, since odd sizes |
|
could occur. |
|
|
|
Since 5.1 |
|
- dyn_load.c declared GC_scratch_last_end_ptr as an extern even if it |
|
was defined as a macro. This prevented the collector from building on |
|
Irix. |
|
- We quietly assumed that indirect mark descriptors were never 0. |
|
Our own typed allocation interface violated that. This could result |
|
in segmentation faults in the marker with typed allocation. |
|
- Fixed a _DUSE_MUNMAP bug in the heap block allocation code. |
|
(Thanks to Ben Hutchings for the patch.) |
|
- Taught the collector about VC++ handling array operator new. |
|
(Thanks again to Ben Hutchings for the patch.) |
|
- The two copies of gc_hdrs.h had diverged. Made one a link to the other |
|
again. |
|
|
|
Since 5.2 |
|
- Fixed _end declaration for OSF1. |
|
- There were lots of spurious leak reports in leak detection mode, caused |
|
by the fact that some pages were not being swept, and hence unmarked |
|
objects weren't making it onto free lists. (This bug dated back to 5.0.) |
|
- Fixed a typo in the liblinuxgc.so Makefile rule. |
|
- Added the GetExitCodeThread to Win32 GC_stop_world to (mostly) work |
|
around a Windows 95 GetOpenFileName problem. (Thanks to Jacob Navia.) |
|
|
To do: |
To do: |
|
- Integrate Linux/SPARC fixes. |
- Very large root set sizes (> 16 MB or so) could cause the collector |
- Very large root set sizes (> 16 MB or so) could cause the collector |
to abort with an unexpected mark stack overflow. (Thanks again to |
to abort with an unexpected mark stack overflow. (Thanks again to |
Peter Chubb.) NOT YET FIXED. Workaround is to increase the initial |
Peter Chubb.) NOT YET FIXED. Workaround is to increase the initial |
|
|
be possible to conditionally intercept mmap and use GC_exclude_static_roots. |
be possible to conditionally intercept mmap and use GC_exclude_static_roots. |
The real fix is to walk rld data structures, which looks possible. |
The real fix is to walk rld data structures, which looks possible. |
- Integrate MIT and DEC pthreads ports. |
- Integrate MIT and DEC pthreads ports. |
- Deal with very uneven black-listing distributions. If all the black listed |
- Incremental collector should handle large objects better. Currently, |
blocks reside in the newly allocated heap section, the heuristic for |
it looks like the whole object is treated as dirty if any part of it |
temporarily ignoring black-listing fails, and the heap grows too much. |
is. |
(This was observed in only one case, and could be worked around, but ...) |
- Cord/cordprnt.c doesn't build on a few platforms (notably PowerPC), since |
- I've started work on rewriting the large block allocator to use approximate |
we make some unwarranted assumptions about how varargs are handled. This |
best fit. There are rare cases in which the current allocator results in |
currently makes the cord-aware versions of printf unusable on some platforms. |
excessive large block fragmentation, even with the 4.13 fixes. This should |
Fixing this is unfortunately not trivial. |
also reduce large block allocation time, whcih has become occasionally |
|
noticable in 4.13. |
|
|
|