~ chicken-core (chicken-5) /tests/test-gc-hooks.scm
Trap1;;;; test-gc-hooks.scm23(import (chicken gc))45#>67static int count = 0;89static void10gc_start(int mode)11{12 printf(">>>>> GC pre hook - mode=%d, count=%d\n", mode, count++);13}1415static void16gc_end(int mode, long ms)17{18 printf("<<<<< GC post hook - mode=%d, count=%d, ms=%ld\n", mode, --count, ms);19}2021<#2223(set-gc-report! #t)2425(foreign-code #<<EOF26C_pre_gc_hook = gc_start;27C_post_gc_hook = gc_end;28EOF29)3031(print "major gc ...")32(gc)33(print "minor gc ...")34(gc #f)35(print "alloc ...")36(make-string 10000000)37(print "resize ...")38(##sys#gc '())39(print "major gc ...")40(gc)41(print "minor gc ...")42(gc #f)4344(assert (zero? (foreign-value "count" int)))