{"id":30092690,"url":"https://github.com/bdwgc/bdwgc","last_synced_at":"2026-02-05T19:01:09.561Z","repository":{"id":1591647,"uuid":"2109456","full_name":"bdwgc/bdwgc","owner":"bdwgc","description":"The Boehm-Demers-Weiser conservative C/C++ Garbage Collector (bdwgc, also known as bdw-gc, boehm-gc, libgc)","archived":false,"fork":false,"pushed_at":"2026-02-03T12:08:22.000Z","size":31898,"stargazers_count":3411,"open_issues_count":182,"forks_count":432,"subscribers_count":93,"default_branch":"master","last_synced_at":"2026-02-03T18:15:28.627Z","etag":null,"topics":["c","c-plus-plus","cplusplus","cpp","cross-platform","garbage-collection","garbage-collector","gc","leak-detection","library","memory-allocation","memory-leak-detection","memory-management","portable"],"latest_commit_sha":null,"homepage":"https://www.hboehm.info/gc/","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bdwgc.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2011-07-26T21:28:36.000Z","updated_at":"2026-02-03T09:45:52.000Z","dependencies_parsed_at":"2023-09-26T22:41:51.784Z","dependency_job_id":"bc4802e1-0542-4cf1-b718-387cd7972ccf","html_url":"https://github.com/bdwgc/bdwgc","commit_stats":{"total_commits":4658,"total_committers":171,"mean_commits":"27.239766081871345","dds":"0.23701159295835117","last_synced_commit":"f21eefafc047240a4d971de5147bf64dd46725fe"},"previous_names":["bdwgc/bdwgc","ivmai/bdwgc"],"tags_count":139,"template":false,"template_full_name":null,"purl":"pkg:github/bdwgc/bdwgc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdwgc%2Fbdwgc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdwgc%2Fbdwgc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdwgc%2Fbdwgc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdwgc%2Fbdwgc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bdwgc","download_url":"https://codeload.github.com/bdwgc/bdwgc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bdwgc%2Fbdwgc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29130094,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-05T18:55:47.139Z","status":"ssl_error","status_checked_at":"2026-02-05T18:55:04.010Z","response_time":65,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","c-plus-plus","cplusplus","cpp","cross-platform","garbage-collection","garbage-collector","gc","leak-detection","library","memory-allocation","memory-leak-detection","memory-management","portable"],"created_at":"2025-08-09T08:02:54.418Z","updated_at":"2026-02-05T19:01:09.553Z","avatar_url":"https://github.com/bdwgc.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"# Boehm-Demers-Weiser Garbage Collector\n\n[![Travis-CI build status](https://app.travis-ci.com/bdwgc/bdwgc.svg?branch=master)](https://app.travis-ci.com/github/bdwgc/bdwgc)\n[![AppVeyor CI build status](https://img.shields.io/appveyor/build/bdwgc/bdwgc.svg?branch=master)](https://ci.appveyor.com/project/bdwgc/bdwgc/branch/master)\n[![GitHub Actions build status (autotools build extra)](https://github.com/bdwgc/bdwgc/actions/workflows/autotools-build-extra.yml/badge.svg?event=push)](https://github.com/bdwgc/bdwgc/actions/workflows/autotools-build-extra.yml?query=branch%3Amaster)\n[![GitHub Actions build status (cmake)](https://github.com/bdwgc/bdwgc/actions/workflows/cmake-build.yml/badge.svg?event=push)](https://github.com/bdwgc/bdwgc/actions/workflows/cmake-build.yml?query=branch%3Amaster)\n[![GitHub Actions build status (cmake extra)](https://github.com/bdwgc/bdwgc/actions/workflows/cmake-build-extra.yml/badge.svg?event=push)](https://github.com/bdwgc/bdwgc/actions/workflows/cmake-build-extra.yml?query=branch%3Amaster)\n[![GitHub Actions build status (cmake cosmo)](https://github.com/bdwgc/bdwgc/actions/workflows/cmake-cosmo.yml/badge.svg?event=push)](https://github.com/bdwgc/bdwgc/actions/workflows/cmake-cosmo.yml?query=branch%3Amaster)\n[![GitHub Actions build status (zig build/test)](https://github.com/bdwgc/bdwgc/actions/workflows/zig-build.yml/badge.svg?event=push)](https://github.com/bdwgc/bdwgc/actions/workflows/zig-build.yml?query=branch%3Amaster)\n[![GitHub Actions build status (zig cross-compile)](https://github.com/bdwgc/bdwgc/actions/workflows/zig-cross-compile.yml/badge.svg?event=push)](https://github.com/bdwgc/bdwgc/actions/workflows/zig-cross-compile.yml?query=branch%3Amaster)\n[![GitHub Actions build status (Makefile.direct)](https://github.com/bdwgc/bdwgc/actions/workflows/make-direct-build.yml/badge.svg?event=push)](https://github.com/bdwgc/bdwgc/actions/workflows/make-direct-build.yml?query=branch%3Amaster)\n[![GitHub Actions status (clang-format)](https://github.com/bdwgc/bdwgc/actions/workflows/clang-format-check.yml/badge.svg?event=push)](https://github.com/bdwgc/bdwgc/actions/workflows/clang-format-check.yml?query=branch%3Amaster)\n[![GitHub Actions status (zig format)](https://github.com/bdwgc/bdwgc/actions/workflows/zig-format-check.yml/badge.svg?event=push)](https://github.com/bdwgc/bdwgc/actions/workflows/zig-format-check.yml?query=branch%3Amaster)\n[![GitHub Actions status (CSA check)](https://github.com/bdwgc/bdwgc/actions/workflows/csa-check.yml/badge.svg?event=push)](https://github.com/bdwgc/bdwgc/actions/workflows/csa-check.yml?query=branch%3Amaster)\n[![GitHub Actions status (spell-check)](https://github.com/bdwgc/bdwgc/actions/workflows/spell-check.yml/badge.svg?event=push)](https://github.com/bdwgc/bdwgc/actions/workflows/spell-check.yml?query=branch%3Amaster)\n[![CodeQL](https://github.com/bdwgc/bdwgc/workflows/CodeQL/badge.svg)](https://github.com/bdwgc/bdwgc/actions/workflows/CodeQL.yml?query=branch%3Amaster)\n[![Coverage status](https://coveralls.io/repos/github/bdwgc/bdwgc/badge.svg?branch=master)](https://coveralls.io/github/bdwgc/bdwgc)\n[![Coverity Scan build status](https://scan.coverity.com/projects/32099/badge.svg)](https://scan.coverity.com/projects/bdwgc-bdwgc)\n[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fbdwgc%2Fbdwgc.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fbdwgc%2Fbdwgc?ref=badge_shield)\n[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/6332/badge)](https://www.bestpractices.dev/projects/6332)\n[![Hits-of-Code](https://hitsofcode.com/github/bdwgc/bdwgc?branch=master)](https://hitsofcode.com/github/bdwgc/bdwgc/view)\n[![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/bdwgc/bdwgc)](https://shields.io/badges/git-hub-code-size-in-bytes)\n[![Github All Releases](https://img.shields.io/github/downloads/bdwgc/bdwgc/total.svg)](https://shields.io/badges/git-hub-downloads-all-assets-all-releases)\n[![Packaging status](https://repology.org/badge/tiny-repos/boehm-gc.svg)](https://repology.org/project/boehm-gc/versions)\n\nThis is version 8.3.0 (next release development) of a conservative garbage\ncollector for C and C++.\n\nLicense: [MIT-style](LICENSE)\n\n\n## Download\n\nYou might find a more recent/stable version on the\n[Download](https://github.com/bdwgc/bdwgc/wiki/Download) page, or\n[BDWGC site](http://www.hboehm.info/gc/).\n\nAlso, the latest bug fixes and new features are available in the\n[development repository](https://github.com/bdwgc/bdwgc).\n\n\n## Overview\n\nThis is intended to be a general purpose, garbage collecting storage\nallocator.  The algorithms used are described in:\n\n * Boehm, H., and M. Weiser, \"Garbage Collection in an Uncooperative\n   Environment\", Software Practice \u0026 Experience, September 1988, pp. 807-820.\n\n * Boehm, H., A. Demers, and S. Shenker, \"Mostly Parallel Garbage Collection\",\n   Proceedings of the ACM SIGPLAN '91 Conference on Programming Language Design\n   and Implementation, SIGPLAN Notices 26, 6 (June 1991), pp. 157-164.\n\n * Boehm, H., \"Space Efficient Conservative Garbage Collection\", Proceedings\n   of the ACM SIGPLAN '91 Conference on Programming Language Design and\n   Implementation, SIGPLAN Notices 28, 6 (June 1993), pp. 197-206.\n\n * Boehm H., \"Reducing Garbage Collector Cache Misses\", Proceedings of the\n   2000 International Symposium on Memory Management.\n\nPossible interactions between the collector and optimizing compilers are\ndiscussed in\n\n * Boehm, H., and D. Chase, \"A Proposal for GC-safe C Compilation\",\n   The Journal of C Language Translation 4, 2 (December 1992).\n\n * Boehm H., \"Simple GC-safe Compilation\", Proceedings of the ACM SIGPLAN '96\n   Conference on Programming Language Design and Implementation.\n\nUnlike the collector described in the second reference, this collector\noperates either with the mutator stopped during the entire collection\n(default) or incrementally during allocations.  (The latter is supported\non fewer machines.)  On the most common platforms, it can be built with or\nwithout multi-threading support.  On some platforms, it can take advantage\nof a multiprocessor to speed up garbage collection.\n\nMany of the ideas underlying the collector have previously been explored\nby others.  Notably, some of the run-time systems developed at Xerox PARC\nin the early 1980s conservatively scanned thread stacks to locate possible\npointers (cf. Paul Rovner, \"On Adding Garbage Collection and Runtime Types\nto a Strongly-Typed Statically Checked, Concurrent Language\" Xerox PARC\nCSL 84-7).  Doug McIlroy wrote a simpler fully conservative collector that\nwas part of version 8 UNIX (tm), but appears to not have received\nwidespread use.\n\nRudimentary tools for use of the collector as a [leak detector](docs/leak.md)\nare included, as is a fairly sophisticated string package \"cord\" that\nmakes use of the collector.  (See [cords.md](docs/cords.md) and\nH.-J. Boehm, R. Atkinson, and M. Plass, \"Ropes: An Alternative to Strings\",\nSoftware Practice and Experience 25, 12 (December 1995), pp. 1315-1330.\nThis is very similar to the \"rope\" package in Xerox Cedar, or the \"rope\"\npackage in the SGI STL or the g++ distribution.)\n\nFurther collector documentation can be found in the\n[overview](docs/overview.md).\n\nSome of the known uses of the collector are listed on the GitHub\n[Known-clients](https://github.com/bdwgc/bdwgc/wiki/Known-clients) page.\n\n\n## General Description\n\nThis is a garbage collecting storage allocator that is intended to be\nused as a plug-in replacement for C's malloc.\n\nSince the collector does not require pointers to be tagged, it does not\nattempt to ensure that all inaccessible storage is reclaimed.  However,\nin our experience, it is typically more successful at reclaiming unused\nmemory than most C programs using explicit deallocation.  Unlike manually\nintroduced leaks, the amount of unreclaimed memory typically stays\nbounded.\n\nIn the following, an \"object\" is defined to be a region of memory allocated\nby the routines described below.\n\nAny objects not intended to be collected must be pointed to either\nfrom other such accessible objects, or from the registers,\nstack, data, or statically allocated bss segments.  Pointers from\nthe stack or registers may point to anywhere inside an object.\nThe same is true for heap pointers if the collector is compiled with\n`ALL_INTERIOR_POINTERS` defined, or `GC_all_interior_pointers` is otherwise\nset, as is now the default.\n\nCompiling without `ALL_INTERIOR_POINTERS` may reduce accidental retention\nof garbage objects, by requiring pointers from the heap to the beginning\nof an object.  But this no longer appears to be a significant\nissue for most programs occupying a small fraction of the possible\naddress space.\n\nThere are a number of routines which modify the pointer recognition\nalgorithm.  `GC_register_displacement` allows certain interior pointers\nto be recognized even if `ALL_INTERIOR_POINTERS` is not defined.\n`GC_malloc_ignore_off_page` allows some pointers into the middle of\nlarge objects to be disregarded, greatly reducing the probability of\naccidental retention of large objects.  For most purposes it seems\nbest to compile with `ALL_INTERIOR_POINTERS` and to use\n`GC_malloc_ignore_off_page` if you get collector warnings from\nallocations of very large objects.  See [here](docs/debugging.md) for details.\n\n*Warning*: pointers inside memory allocated by the standard (system) `malloc`\nare not seen by the garbage collector.  Thus objects pointed to only from such\na region may be prematurely deallocated.  It is thus suggested that the\nstandard `malloc` be used only for memory regions, such as I/O buffers, that\nare guaranteed not to contain pointers to garbage collectible memory.\nPointers in C language automatic, static, or register variables,\nare correctly recognized.  (Note that `GC_malloc_uncollectable` has\nsemantics similar to standard malloc, but allocates objects that are\ntraced by the collector.)\n\n*Warning*: the collector does not always know how to find pointers in data\nareas that are associated with dynamic libraries.  This is easy to remedy\nif you know how to find those data areas on your operating system (see\n`GC_add_roots`).  Code for doing this under SunOS, Irix 5.x and 6.x, HP/UX,\nAlpha OSF/1 (Tru64 UNIX), Linux, and Win32 is included and used by default.\n(See [README.win32](docs/platforms/README.win32) and\n[README.win64](docs/platforms/README.win64) for Windows details.)  On other\nsystems, pointers from dynamic library data areas may not be considered by the\ncollector.  If you are writing a program that depends on the collector\nscanning dynamic library data areas, it may be a good idea to include at least\none call to `GC_is_visible` to ensure that those areas are visible to the\ncollector.\n\nNote that the garbage collector does not need to be informed of shared\nread-only data.  However, if the shared library mechanism can introduce\ndiscontiguous data areas that may contain pointers then the collector does\nneed to be informed.\n\nSignal processing for most signals may be deferred during collection,\nand during uninterruptible parts of the allocation process.\nLike standard ANSI C mallocs, by default it is unsafe to invoke\nmalloc (and other GC routines) from a signal handler while another\nmalloc call may be in progress.\n\nThe allocator/collector can also be configured for thread-safe operation.\n(Full signal safety can also be achieved, but only at the cost of two system\ncalls per malloc, which is usually unacceptable.)\n\n*Warning*: the collector does not guarantee to scan thread-local storage\n(e.g. of the kind accessed with `pthread_getspecific`).  The collector\ndoes scan thread stacks, though, so generally the best solution is to\nensure that any pointers stored in thread-local storage are also\nstored on the thread's stack for the duration of their lifetime.\n(This is arguably a longstanding bug, but it has not been fixed yet.)\n\n\n## Building and Installing\n\nThere are multiple ways to build the collector:\n\n  * CMake (it is the recommended way)\n  * GNU autoconf/automake\n  * Zig (experimental)\n  * MS nmake (directly)\n  * Makefile.direct\n  * Manual C compilation\n\n### CMake\n\nThe simplest way to build `gc` library (as well as `cord` library) and run\nthe tests using CMake:\n\n```sh\nmkdir build\ncd build\ncmake ..\ncmake --build .\nctest\n```\n\nThis is the most cross-platform way of building the library.\nSee [cmake.md](docs/cmake.md) for details.\n\n### GNU Autoconf/Automake\n\nPlease note that the collector source repository does not contain `configure`\nand similar auto-generated files, thus the full procedure of `autoconf`-based\nbuild of the collector from the source repository could look like:\n\n```sh\n./autogen.sh\n./configure\nmake check\n```\n\nThe GNU style build process understands the usual targets and options.\n`make install` installs `gc` and `cord` libraries.  Try `./configure --help`\nto see all the configuration options.  It is currently not possible to\nexercise all combinations of build options this way.\n\nSee [autoconf.md](docs/autoconf.md) for details.\n\n### Zig\n\nBuilding and testing the collector using zig is straight forward in its\nsimplest form:\n\n```sh\nzig build test\n```\n\nIt is possible to configure the build through the use of variables, e.g.\n`zig build -Denable_redirect_malloc -Denable_threads=false`.  Zig offers\nexcellent cross-compilation functionality, it is configurable like this:\n\n```sh\nzig build -Dtarget=riscv64-linux-musl\n```\n\nThe appropriate Zig binary package file could be downloaded from the official\n[Zig releases](https://ziglang.org/download/) page.\n\n### MS nmake\n\nOn Windows, assuming the Microsoft build tools are installed and suitably\nconfigured, it is possible to build the library and run the tests using\n`nmake` directly, e.g. by by typing `nmake -f NT_MAKEFILE check`.  However,\nthe recommended way is to use cmake as described above.\n\nSee [README.win32](docs/platforms/README.win32) for details.\n\n### Makefile.direct\n\nFor the old-style (classic) makefile-based build process, typing\n`make -f Makefile.direct check` will automatically build `gc`, `cord`\nlibraries, then run a number of tests such as `gctest`.  The test is\na somewhat superficial test of collector functionality.  Failure is indicated\nby a core dump or a message to the effect that the collector is broken.\n`gctest` may take a dozen of seconds to run on reasonable 2023 vintage 64-bit\ndesktops.  It may use up to about 30 MB of memory.\n\n`Makefile.direct` file generates a `libgc.a` file which you should link\nagainst.\n\n### Manual C Compilation\n\nFinally, on most targets, the collector could be built and tested directly\nwith a single compiler invocation, like this (the sample lacks multi-threading\nsupport):\n\n```sh\ncc -I include -o gctest tests/gctest.c extra/gc.c \u0026\u0026 ./gctest\n```\n\nE.g., this could be convenient for a debugging purpose.\n\n### Configurable Macros\n\nThe library can be configured more precisely during the build by defining\nthe macros listed in [macros.md](docs/macros.md) file.\n\nThe library is built with multi-threading support enabled (i.e. for\nthread-safe operation) by default, unless explicitly disabled by:\n\n  * `-Denable_threads=false` option passed to `cmake` or `zig build`\n  * `--disable-threads` option passed to `./configure`\n\nThe collector operates silently in the default configuration.\nIn the event of issues, this can usually be changed by defining the\n`GC_PRINT_STATS` or `GC_PRINT_VERBOSE_STATS` environment variables.  This\nwill result in a few lines of descriptive output for each collection.\n(The given statistics exhibit a few peculiarities.\nThings do not appear to add up for a variety of reasons, most notably\nfragmentation losses.  These are probably much more significant for the\ncontrived program `gctest` than for your application.)\n\n### Atomic_ops\n\nUse (cloning) of `libatomic_ops` is now optional provided the compiler\nsupports atomic intrinsics.  Most modern compilers do.  The notable exception\nis the MS compiler (as of Visual Studio 2022).\n\nIf needed, most OS distributes have `libatomic_ops` package; alternatively,\nyou can download or clone it from\n[libatomic_ops](https://github.com/bdwgc/libatomic_ops) repository on GitHub.\n\n\n## Portability\n\nThe collector currently is designed to run essentially unmodified on\nmachines that use a flat 32-bit or 64-bit address space.\nThat includes the vast majority of Workstations and x86 (i386 or later) PCs.\n\nIn a few cases (e.g., OS/2, Win32) a separate makefile is supplied; these have\na separate host-specific docs/platforms/README.* file.\n\nDynamic libraries are completely supported only under SunOS/Solaris,\n(and even that support is not functional on the last Sun 3 release),\nLinux, FreeBSD, NetBSD, Irix, HP/UX, Win32 (not win32s) and Tru64 UNIX\non DEC AXP machines plus perhaps a few others listed near the top\nof dyn_load.c.  On other machines we recommend that you do one of\nthe following:\n\n  1. Add dynamic library support (and send us the code).\n\n  2. Use static versions of the libraries.\n\n  3. Arrange for dynamic libraries to use the standard malloc. This is still\n     dangerous if the library stores a pointer to a garbage-collected object.\n     But nearly all standard interfaces prohibit this, because they deal\n     correctly with pointers to stack allocated objects.  (`strtok` is an\n     exception.  Do not use it.)\n\nIn all cases we assume that pointer alignment is consistent with that\nenforced by the standard C compilers.  If you use a nonstandard compiler\nyou may have to adjust the alignment parameters defined in\n`include/private/gc_priv.h` file.  Note that this may also be an issue with\npacked records/structs, if those enforce less alignment for pointers.\n\nA port to a machine that is not byte addressed, or does not use 32 bit\nor 64 bit addresses will require a major effort.  A port to plain MSDOS\nor win16 is hard.\n\nFor machines not already mentioned, or for nonstandard compilers,\nsome porting suggestions are provided [here](docs/porting.md).\n\n\n## The C Interface to the Allocator\n\nThe following routines are intended to be directly called by the user.\nNote that usually only `GC_malloc` is necessary.  `GC_clear_roots` and\n`GC_add_roots` calls may be required if the collector has to trace\nfrom nonstandard places (e.g. from dynamic library data areas on a\nmachine on which the collector does not already understand them.)  On\nsome machines, it may be desirable to set `GC_stackbottom` to a good\napproximation of the stack base (bottom).\n\nClient code may include `gc.h` file, which defines all of the following, plus\nmany others.\n\n  1. `GC_malloc(bytes)` - Allocate an object of a given size.\n     Unlike `malloc`, the object is cleared before being returned to the user.\n     `GC_malloc` will invoke the garbage collector when it determines this to\n     be appropriate.  `GC_malloc` may return 0 if it is unable to acquire\n     sufficient space from the operating system.  This is the most probable\n     consequence of running out of space.  Other possible consequences are\n     that a function call will fail due to lack of stack space, or that the\n     collector will fail in other ways because it cannot maintain its internal\n     data structures, or that a crucial system process will fail and take down\n     the machine.  Most of these possibilities are independent of the `malloc`\n     implementation.\n\n  2. `GC_malloc_atomic(bytes)` - Allocate an object of a given size that\n     is guaranteed not to contain any pointers.  The returned object is not\n     guaranteed to be cleared.  (Can always be replaced by `GC_malloc`, but\n     results in faster collection times.  The collector will probably run\n     faster if large character arrays, etc. are allocated with\n     `GC_malloc_atomic` than if they are statically allocated.)\n\n  3. `GC_realloc(object, new_bytes)` and `GC_reallocf(object, new_bytes)` -\n     Change the size of object to be of a given size.  Returns a pointer to\n     the new object, which may, or may not, be the same as the pointer to the\n     old object.  The new object is taken to be atomic if and only if the old\n     one was.  If the new object is composite and larger than the original\n     object, then the newly added bytes are cleared. This is very likely to\n     allocate a new object.\n\n  4. `GC_free(object)`, `GC_freezero(object, bytes_to_clear)` - Explicitly\n     deallocate an object returned by `GC_malloc` or `GC_malloc_atomic`,\n     or friends.  Not necessary, but can be used to minimize collections if\n     performance is critical.  Probably a performance loss could occur for\n     very small objects (not greater than 8 bytes).  `GC_freezero` ensures\n     the object is zero-filled before its deallocation.\n\n  5. `GC_expand_hp(bytes)` - Explicitly increase the heap size.  (This is\n     normally done automatically if a garbage collection failed to reclaim\n     enough memory.  Explicit calls to `GC_expand_hp` may prevent\n     unnecessarily frequent collections at program startup.)\n\n  6. `GC_malloc_ignore_off_page(bytes)` - Identical to `GC_malloc`, but the\n     client promises to keep a pointer to the somewhere within the first GC\n     heap block (512 .. 4096 bytes or even more, depending on the\n     configuration) of the object while it is live.  (This pointer should\n     normally be declared `volatile` to prevent interference from compiler\n     optimizations.)  This is the recommended way to allocate anything that\n     is likely to be larger than 100 KB or so.  (`GC_malloc` may result in\n     a failure to reclaim such objects.)\n\n  7. `GC_set_warn_proc(proc)` - Can be used to redirect warnings from the\n     collector.  Such warnings should be rare, and should not be ignored\n     during code development.\n\n  8. `GC_enable_incremental()` - Enables generational and incremental\n     collection.  Useful for large heaps on machines that provide access to\n     page dirty information.  Some dirty bit implementations may interfere\n     with debugging (by catching address faults) and place restrictions on\n     heap arguments to system calls (since write faults inside a system call\n     may not be handled well).\n\n  9. `GC_register_finalizer(object, proc, data, 0, 0)` and friends - Allow\n     for registration of finalization code.  User-supplied finalization code\n     (`(*proc)(object, data)`) is invoked after object becomes unreachable.\n     For more sophisticated uses, and for finalization ordering issues, see\n     `gc.h` file.\n\nThe global variable `GC_free_space_divisor` may be adjusted up from it\ndefault value of 3 to use less space and more collection time, or down for\nthe opposite effect.  Setting it to 1 will almost disable collections\nand cause all allocations to simply grow the heap.\n\nThe variable `GC_non_gc_bytes`, which is normally 0, may be changed to reflect\nthe amount of memory allocated by the above routines that should not be\nconsidered as a candidate for collection.  Careless use may, of course, result\nin excessive memory consumption.\n\nSome additional tuning is possible through the parameters defined\nnear the top of `include/private/gc_priv.h` file.\n\nIf only `GC_malloc` is intended to be used, it might be appropriate to define\nlike:\n\n```c\n#define malloc(n) GC_malloc(n)\n#define calloc(m, n) GC_malloc((m) * (n))\n```\n\nFor small pieces of *very* allocation-intensive code, `gc_inline.h` file\nincludes some allocation macros that may be used in place of `GC_malloc` and\nfriends.\n\nAll externally visible names in the garbage collector start with `GC_`.\nTo avoid name conflicts, client code should avoid this prefix, except when\naccessing garbage collector routines.\n\nThere are provisions for allocation with explicit type information.\nThis is rarely necessary.  Details can be found in `gc_typed.h` file.\n\n\n## The C++ Interface to the Allocator\n\nThe Ellis-Hull C++ interface to the collector is included in the collector\ndistribution.  If you intend to use this, type\n`./configure --enable-cplusplus \u0026\u0026 make` (or\n`cmake -D enable_cplusplus=ON . \u0026\u0026 cmake --build .`, or\n`make -f Makefile.direct c++` depending on the build system you use).\nThis creates `libgccpp.a` and `libgctba.a` files, or their shared library\nequivalents (`libgccpp.so` and `libgctba.so` files).  You should link with\neither the first (`gccpp`) or the second one (`gctba`), but not both.\nSee `gc_cpp.h` file and [here](docs/gcinterface.md) for the definition of the\ninterface.  This interface tries to approximate the Ellis-Detlefs C++ garbage\ncollection proposal without compiler changes.\n\nVery often it will also be necessary to use `gc_allocator.h` file and the\nallocator declared there to construct STL data structures.  Otherwise\nsubobjects of STL data structures will be allocated using a system\nallocator, and objects they refer to may be prematurely collected.\n\n\n## Use as Leak Detector\n\nThe collector may be used to track down leaks in C programs that are\nintended to run with `malloc`/`free` (e.g. code with extreme real-time or\nportability constraints).  To do so define `FIND_LEAK` macro (e.g. by passing\nit in `CFLAGS_EXTRA` variable of `Makefile.direct` file).  This will cause\nthe collector to print a human-readable object description whenever\nan inaccessible object is found that has not been explicitly freed.\nSuch objects will also be automatically reclaimed.\n\nIf all objects are allocated with `GC_DEBUG_MALLOC` (see the next section)\nthen, by default, the human-readable object description will at least contain\nthe source file and the line number at which the leaked object was allocated.\nThis may sometimes be sufficient.  (On a few machines, it will also report\na cryptic stack trace.  If this is not symbolic, it can sometimes be called\ninto a symbolic stack trace by invoking program \"foo\" with\n`tools/callprocs.sh foo`.  It is a short shell script that invokes adb to\nexpand program counter values to symbolic addresses.  It was largely supplied\nby Scott Schwartz.)\n\nNote that the debugging facilities described in the next section can\nsometimes be slightly *less* effective in the leak finding mode, because\n`GC_debug_free` actually results in reuse of the object.  (Otherwise the\nobject is simply marked invalid.)  Also, note that most GC tests are not\ndesigned to run meaningfully in `FIND_LEAK` mode.\n\n\n## Debugging Facilities\n\nThe routines `GC_debug_malloc`, `GC_debug_malloc_atomic`, `GC_debug_realloc`,\n`GC_debug_reallocf` and `GC_debug_free` provide an alternate interface to the\ncollector, which provides some help with memory overwrite errors, and the\nlike.  Objects allocated in this way are annotated with additional\ninformation.  Some of this information is checked during garbage collections,\nand detected inconsistencies are reported to `stderr`.\n\nSimple cases of writing past the end of an allocated object should\nbe caught if the object is explicitly deallocated, or if the\ncollector is invoked while the object is live.  The first deallocation\nof an object will clear the debugging info associated with an\nobject, so accidentally repeated calls to `GC_debug_free` will report the\ndeallocation of an object without debugging information.  Out of\nmemory errors will be reported to `stderr`, in addition to returning `NULL`.\n\n`GC_debug_malloc` checking during garbage collection is enabled\nwith the first call to this function.  This will result in some\nslowdown during collections.  If frequent heap checks are desired,\nthis can be achieved by explicitly invoking `GC_gcollect`, e.g. from\nthe debugger.\n\n`GC_debug_malloc`-allocated objects should not be passed to `GC_realloc`,\n`GC_reallocf`, `GC_free`, `GC_freezero`, and conversely.  It is however\nacceptable to allocate only some objects with `GC_debug_malloc`, and to use\n`GC_malloc` for other objects, provided the two pools are kept distinct.\nIn this case, there is a very low probability that `GC_malloc`-allocated\nobjects may be misidentified as having been overwritten.  This should happen\nwith probability at most one in `2**32`.  This probability is zero if\n`GC_debug_malloc` is never called.\n\n`GC_debug_malloc`, `GC_debug_malloc_atomic`, `GC_debug_realloc` and\n`GC_debug_reallocf` take two additional trailing arguments, a string and\nan integer.  These are not interpreted by the allocator.  They are stored in\nthe object (the string is not copied).  If an error involving the object is\ndetected, they are printed.\n\nThe macros `GC_MALLOC`, `GC_MALLOC_ATOMIC`, `GC_REALLOC`, `GC_FREE`,\n`GC_REGISTER_FINALIZER` and friends are also provided.  These require the same\narguments as the corresponding (non-debugging) routines.  If `gc.h` file is\nincluded with `GC_DEBUG` defined, they call the debugging versions of these\nfunctions, passing the current file name and line number as the two\nextra arguments, where appropriate.  If `gc.h` file is included without\n`GC_DEBUG` macro defined then all these macros will instead be defined to\ntheir non-debugging equivalents.  (`GC_REGISTER_FINALIZER` is necessary, since\npointers to objects with debugging information are really pointers to\na displacement of 16 bytes from the object beginning, and some translation is\nnecessary when finalization routines are invoked.  For details, about what is\nstored in the header, see the definition of the type `oh` in `dbg_mlc.h`\nfile.)\n\n\n## Incremental/Generational Collection\n\nThe collector normally interrupts client code for the duration of\na garbage collection mark phase.  This may be unacceptable if interactive\nresponse is needed for programs with large heaps.  The collector\ncan also run in a \"generational\" mode, in which it usually attempts to\ncollect only objects allocated since the last garbage collection.\nFurthermore, in this mode, garbage collections run mostly incrementally,\nwith a small amount of work performed in response to each of a large number of\n`GC_malloc` requests.\n\nThis mode is enabled by a call to `GC_enable_incremental`.\n\nIncremental and generational collection is effective in reducing\npause times only if the collector has some way to tell which objects\nor pages have been recently modified.  The collector uses two sources\nof information:\n\n  1. Information provided by the VM system.  This may be provided in one of\n     several forms.  Under Solaris 2.x (and potentially under other similar\n     systems) information on dirty pages can be read from the `/proc` file\n     system.  Under other systems (e.g. SunOS 4.x) it is possible to\n     write-protect the heap, and catch the resulting faults.  On these systems\n     we require that system calls writing to the heap (other than `read`) be\n     handled specially by client code.  See `os_dep.c` for details.\n\n  2. Information supplied by the programmer.  The object is considered dirty\n     after a call to `GC_end_stubborn_change` provided the library has been\n     compiled suitably.  It is typically not worth using for short-lived\n     objects.  Note that bugs caused by a missing `GC_end_stubborn_change` or\n     `GC_reachable_here` call are likely to be observed very infrequently and\n     hard to trace.\n\n\n## Bugs\n\nAny memory that does not have a recognizable pointer to it will be reclaimed.\nExclusive-or'ing forward and backward links in a list does not cut it.\n\nSome C optimizers may lose the last undisguised pointer to a memory\nobject as a consequence of clever optimizations.  This has almost\nnever been observed in practice.\n\nThis is not a real-time collector.  In the standard configuration,\npercentage of time required for collection should be constant across\nheap sizes.  But collection pauses will increase for larger heaps.\nThey will decrease with the number of processors if parallel marking\nis enabled.\n\n(On 2007 vintage machines, GC times may be on the order of 5 ms\nper MB of accessible memory that needs to be scanned and processed.\nYour mileage may vary.)  The incremental/generational collection facility\nmay help in some cases.\n\n\n## Feedback, Contribution, Questions and Notifications\n\nPlease address bug reports and new feature ideas to\n[GitHub issues](https://github.com/bdwgc/bdwgc/issues).  Before the\nsubmission please check that it has not been done yet by someone else.\n\nIf you want to contribute, submit\na [pull request](https://github.com/bdwgc/bdwgc/pulls) to GitHub.\nPlease process the modified files with clang-format before the submission.\n\nIf you need help, use\n[Stack Overflow](https://stackoverflow.com/questions/tagged/boehm-gc).\nOlder technical discussions are available in `bdwgc` mailing list archive - it\ncan be downloaded as a\n[compressed file](https://github.com/bdwgc/bdwgc/files/1038163/bdwgc-mailing-list-archive-2017_04.tar.gz)\nor browsed at [Narkive](http://bdwgc.opendylan.narkive.com).\n\nTo get new release announcements, subscribe to\n[RSS feed](https://github.com/bdwgc/bdwgc/releases.atom).\n(To receive the notifications by email, a 3rd-party free service like\n[IFTTT RSS Feed](https://ifttt.com/feed) can be setup.)\nTo be notified on all issues, please\n[watch](https://github.com/bdwgc/bdwgc/watchers) the project on\nGitHub.\n\n\n## Copyright \u0026 Warranty, Contributors\n\nOur intent is to make it easy to use bdwgc (libgc), in both free and\nproprietary software.  Hence, the Boehm-Demers-Weiser conservative garbage\ncollector code that we expect to be linked dynamically or statically into\na client application is covered by own license, which is similar in\nspirit to an MIT-style one.\n\nThe exact licensing information is provided in [LICENSE](LICENSE) file.\n\nAll the contributors are listed in [AUTHORS](AUTHORS) file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbdwgc%2Fbdwgc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbdwgc%2Fbdwgc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbdwgc%2Fbdwgc/lists"}