A garbage collector for C and C++
http://homepage2.nifty.com/aito/gc/gc.html
http://www.namikilab.tuat.ac.jp/~sasada/prog/boehmgc.html
http://www.nslabs.jp/boehmgc.rhtml
簡単Boehm GCによるC/C++メモリリーク検知
コンパイルが通ることの確認のみ。
$ sudo apt-get libgc-dev
/* gc_test.c */ #include <stdio.h> #include <string.h> #include <stdlib.h> #include <gc.h> int main (int argc, char** argv) { char *buf = GC_malloc_atomic(100); strcpy(buf, "hoge"); printf("%s\n", buf); return 0; }
$ gcc gc_test.c -I/usr/include/gc -L/usr/lib -lgc $ ./a.out
setup.exe で libgc を入れる。