Boehm-Demers-Weiser garbage collector, short for Boehm GC - Conservative garbage collector for C and C ++ languages, used by many projects in C, C ++, as well as other development environments including GNU Compiler for Java. Portable.NET and .NET Mono implementation. It runs on many operating systems, including many Unix variants, Microsoft Windows and OS X, and provides advanced features such as incremental, parallel, and different finalization syntax.

Boehm GC is free software and is available under a X11-like license. Example The garbage collector works with almost unchanged C programs, you only need to change the malloc call to GC_malloc, realloc to GC_realloc, and remove the free calls. The following code shows how to use Boehm instead of malloc and free in C [1]. #include "gc.h" #include <assert.h> #include <stdio.h> int main() { int i; GC_INIT(); for (i = 0; i < 10000000; ++i) { int **p = (int **) GC_MALLOC(sizeof (int *)); int *q = (int *) GC_MALLOC_ATOMIC(sizeof (int)); assert(*p == 0); *p = (int *) GC_REALLOC(q, 2 * sizeof (int)); if (i % 100000 == 0) printf("Heap size = %d\n", GC_get_heap_size()); } return 0; }

wiki

Comments

Popular posts from this blog

Association of Jewish handicrafts "Jad Charuzim"

Grouping Red Arrows

Stanisław Kryński (translator)