⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readme

📁 Boost provides free peer-reviewed portable C++ source libraries. We emphasize libraries that work
💻
📖 第 1 页 / 共 2 页
字号:
Copyright (c) 1988, 1989 Hans-J. Boehm, Alan J. DemersCopyright (c) 1991-1996 by Xerox Corporation.  All rights reserved.Copyright (c) 1996-1999 by Silicon Graphics.  All rights reserved.Copyright (c) 1999-2005 Hewlett-Packard Development Company, L.P.The file linux_threads.c is alsoCopyright (c) 1998 by Fergus Henderson.  All rights reserved.The files Makefile.am, and configure.in areCopyright (c) 2001 by Red Hat Inc. All rights reserved.Several files supporting GNU-style builds are copyrighted by the FreeSoftware Foundation, and carry a different license from that givenbelow.  The files included in the libatomic_ops distribution (includedhere) use either the license below, or a similar MIT-style license,or, for some files not actually used by the garbage-collector library, theGPL.THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSEDOR IMPLIED.  ANY USE IS AT YOUR OWN RISK.Permission is hereby granted to use or copy this programfor any purpose,  provided the above notices are retained on all copies.Permission to modify the code and to distribute modified code is granted,provided the above notices are retained, and a notice that the code wasmodified is included with the above copyright notice.A few of the files needed to use the GNU-style build procedure come withslightly different licenses, though they are all similar in spirit.  A feware GPL'ed, but with an exception that should cover all uses in thecollector.  (If you are concerned about such things, I recommend you lookat the notice in config.guess or ltmain.sh.)This is version 7.0 of a conservative garbage collector for C and C++.You might find a more recent version of this athttp://www.hpl.hp.com/personal/Hans_Boehm/gcOVERVIEW    This is intended to be a general purpose, garbage collecting storageallocator.  The algorithms used are described in:Boehm, H., and M. Weiser, "Garbage Collection in an Uncooperative Environment",Software Practice & Experience, September 1988, pp. 807-820.Boehm, H., A. Demers, and S. Shenker, "Mostly Parallel Garbage Collection",Proceedings of the ACM SIGPLAN '91 Conference on Programming Language Designand Implementation, SIGPLAN Notices 26, 6 (June 1991), pp. 157-164.Boehm, H., "Space Efficient Conservative Garbage Collection", Proceedingsof the ACM SIGPLAN '91 Conference on Programming Language Design andImplementation, SIGPLAN Notices 28, 6 (June 1993), pp. 197-206.Boehm H., "Reducing Garbage Collector Cache Misses", Proceedings of the2000 International Symposium on Memory Management.  Possible interactions between the collector and optimizing compilers arediscussed inBoehm, H., and D. Chase, "A Proposal for GC-safe C Compilation",The Journal of C Language Translation 4, 2 (December 1992).andBoehm H., "Simple GC-safe Compilation", Proceedingsof the ACM SIGPLAN '96 Conference on Programming Language Design andImplementation.(Some of these are also available fromhttp://www.hpl.hp.com/personal/Hans_Boehm/papers/, among other places.)  Unlike the collector described in the second reference, this collectoroperates either with the mutator stopped during the entire collection(default) or incrementally during allocations.  (The latter is supportedon fewer machines.)  On the most common platforms, it can be builtwith or without thread support.  On a few platforms, it can take advantageof a multiprocessor to speed up garbage collection.  Many of the ideas underlying the collector have previously been exploredby others.  Notably, some of the run-time systems developed at Xerox PARCin the early 1980s conservatively scanned thread stacks to locate possiblepointers (cf. Paul Rovner, "On Adding Garbage Collection and Runtime Typesto a Strongly-Typed Statically Checked, Concurrent Language"  Xerox PARCCSL 84-7).  Doug McIlroy wrote a simpler fully conservative collector thatwas part of version 8 UNIX (tm), but appears to not have receivedwidespread use.  Rudimentary tools for use of the collector as a leak detector are included(see http://www.hpl.hp.com/personal/Hans_Boehm/gc/leak.html),as is a fairly sophisticated string package "cord" that makes use of thecollector.  (See doc/README.cords and H.-J. Boehm, R. Atkinson, and M. Plass,"Ropes: An Alternative to Strings", Software Practice and Experience 25, 12(December 1995), pp. 1315-1330.  This is very similar to the "rope" packagein Xerox Cedar, or the "rope" package in the SGI STL or the g++ distribution.)Further collector documantation can be found athttp://www.hpl.hp.com/personal/Hans_Boehm/gcGENERAL DESCRIPTION  This is a garbage collecting storage allocator that is intended to beused as a plug-in replacement for C's malloc.  Since the collector does not require pointers to be tagged, it does notattempt to ensure that all inaccessible storage is reclaimed.  However,in our experience, it is typically more successful at reclaiming unusedmemory than most C programs using explicit deallocation.  Unlike manuallyintroduced leaks, the amount of unreclaimed memory typically staysbounded.  In the following, an "object" is defined to be a region of memory allocatedby the routines described below.    Any objects not intended to be collected must be pointed to eitherfrom other such accessible objects, or from the registers,stack, data, or statically allocated bss segments.  Pointers fromthe stack or registers may point to anywhere inside an object.The same is true for heap pointers if the collector is compiled withALL_INTERIOR_POINTERS defined, or GC_all_interior_pointers is otherwiseset, as is now the default.Compiling without ALL_INTERIOR_POINTERS may reduce accidental retentionof garbage objects, by requiring pointers from the heap to to the beginningof an object.  But this no longer appears to be a significantissue for most programs occupying a small fraction of the possibleaddress space.There are a number of routines which modify the pointer recognitionalgorithm.  GC_register_displacement allows certain interior pointersto be recognized even if ALL_INTERIOR_POINTERS is nor defined.GC_malloc_ignore_off_page allows some pointers into the middle of large objectsto be disregarded, greatly reducing the probablility of accidentalretention of large objects.  For most purposes it seems best to compilewith ALL_INTERIOR_POINTERS and to use GC_malloc_ignore_off_page ifyou get collector warnings from allocations of very large objects.See README.debugging for details.  WARNING: pointers inside memory allocated by the standard "malloc" are notseen by the garbage collector.  Thus objects pointed to only from such aregion may be prematurely deallocated.  It is thus suggested that thestandard "malloc" be used only for memory regions, such as I/O buffers, thatare guaranteed not to contain pointers to garbage collectable memory.Pointers in C language automatic, static, or register variables,are correctly recognized.  (Note that GC_malloc_uncollectable has semanticssimilar to standard malloc, but allocates objects that are traced by thecollector.)  WARNING: the collector does not always know how to find pointers in dataareas that are associated with dynamic libraries.  This is easy toremedy IF you know how to find those data areas on your operatingsystem (see GC_add_roots).  Code for doing this under SunOS, IRIX 5.X and 6.X,HP/UX, Alpha OSF/1, Linux, and win32 is included and used by default.  (SeeREADME.win32 for win32 details.)  On other systems pointers from dynamiclibrary data areas may not be considered by the collector.If you're writing a program that depends on the collector scanningdynamic library data areas, it may be a good idea to include at leastone call to GC_is_visible() to ensure that those areas are visibleto the collector.  Note that the garbage collector does not need to be informed of sharedread-only data.  However if the shared library mechanism can introducediscontiguous data areas that may contain pointers, then the collector doesneed to be informed.  Signal processing for most signals may be deferred during collection,and during uninterruptible parts of the allocation process.Like standard ANSI C mallocs, by default it is unsafe to invokemalloc (and other GC routines) from a signal handler while anothermalloc call may be in progress. Removing -DNO_SIGNALS from Makefileattempts to remedy that.  But that may not be reliable with a compiler thatsubstantially reorders memory operations inside GC_malloc.  The allocator/collector can also be configured for thread-safe operation.(Full signal safety can also be achieved, but only at the cost of two systemcalls per malloc, which is usually unacceptable.)WARNING: the collector does not guarantee to scan thread-local storage(e.g. of the kind accessed with pthread_getspecific()).  The collectordoes scan thread stacks, though, so generally the best solution is toensure that any pointers stored in thread-local storage are alsostored on the thread's stack for the duration of their lifetime.(This is arguably a longstanding bug, but it hasn't been fixed yet.)INSTALLATION AND PORTABILITY  As distributed, the collector operates silentlyIn the event of problems, this can usually be changed by defining theGC_PRINT_STATS or GC_PRINT_VERBOSE_STATS environment variables.  Thiswill result in a few lines of descriptive output for each collection.(The given statistics exhibit a few peculiarities.Things don't appear to add up for a variety of reasons, most notablyfragmentation losses.  These are probably much more significant for thecontrived program "test.c" than for your application.)  On most Un*x-like platforms, the collector can be built either using aGNU autoconf-based build infrastructure (type "configure; make" in thesimplest case), or with a classic makefile by itself (type"cp Makefile.direct Makefile; make").  Here we focus on the latter option.On other platforms, typically only the latter option is available, thoughwith a different supplied Makefile.)  Typing "make test" nstead of "make" will automatically build the collectorand then run setjmp_test and gctest. Setjmp_test will give you informationabout configuring the collector, which is useful primarily if you havea machine that's not already supported.  Gctest is a somewhat superficialtest of collector functionality.  Failure is indicated by a core dump ora message to the effect that the collector is broken.  Gctest takes about a second to two to run on reasonable 2007 vintage desktops.It may use up to about 30MB of memory.  (Themulti-threaded version will use more.  64-bit versions may use more.)"Make test" will also, as its last step, attempt to build and test the"cord" string library.)  The Makefile will generate a library gc.a which you should link against.Typing "make cords" will add the cord library to gc.a.Note that this requires an ANSI C compiler.  It is suggested that if you need to replace a piece of the collector(e.g. GC_mark_rts.c) you simply list your version ahead of gc.a on theld command line, rather than replacing the one in gc.a.  (This willgenerate numerous warnings under some versions of AIX, but it stillworks.)  All include files that need to be used by clients will be put in theinclude subdirectory.  (Normally this is just gc.h.  "Make cords" adds"cord.h" and "ec.h".)  The collector currently is designed to run essentially unmodified onmachines that use a flat 32-bit or 64-bit address space.That includes the vast majority of Workstations and X86 (X >= 3) PCs.(The list here was deleted because it was getting too long and constantlyout of date.)  In a few cases (Amiga, OS/2, Win32, MacOS) a separate makefileor equivalent is supplied.  Many of these have separate README.systemfiles.  Dynamic libraries are completely supported only under SunOS/Solaris,(and even that support is not functional on the last Sun 3 release),Linux, FreeBSD, NetBSD, IRIX 5&6, HP/UX, Win32 (not Win32S) and OSF/1on DEC AXP machines plus perhaps a few others listed near the topof dyn_load.c.  On other machines we recommend that you do one ofthe following:  1) Add dynamic library support (and send us the code).  2) Use static versions of the libraries.  3) Arrange for dynamic libraries to use the standard malloc.     This is still dangerous if the library stores a pointer to a     garbage collected object.  But nearly all standard interfaces     prohibit this, because they deal correctly with pointers     to stack allocated objects.  (Strtok is an exception.  Don't     use it.)  In all cases we assume that pointer alignment is consistent with thatenforced by the standard C compilers.  If you use a nonstandard compileryou may have to adjust the alignment parameters defined in gc_priv.h.Note that this may also be an issue with packed records/structs, if thoseenforce less alignment for pointers.  A port to a machine that is not byte addressed, or does not use 32 bitor 64 bit addresses will require a major effort.  A port to plain MSDOSor win16 is hard.  For machines not already mentioned, or for nonstandard compilers,some porting suggestions are provided in the "porting.html" file.THE C INTERFACE TO THE ALLOCATOR  The following routines are intended to be directly called by the user.Note that usually only GC_malloc is necessary.  GC_clear_roots and GC_add_rootscalls may be required if the collector has to trace from nonstandard places(e.g. from dynamic library data areas on a machine on which the 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -