On Sun 27 Nov 2011 22:25, l...@gnu.org (Ludovic Courtès) writes:

> A longer term option may be to augment libgc with something akin to our
> old scm_gc_register_collectable_memory.

This is also necessary, as it turns out.  I added
scm_gc_register_allocation, which will simply run a GC every so often.

Currently the heuristic is that when GC runs, a counter is reset to be
equal to the current GC heap size.  scm_gc_register_allocation(size_t)
decrements this counter.  When it wraps around, we run GC.

I made scm_realloc call scm_gc_register_allocation.  I also installed
custom gmp allocators that call scm_malloc and friends -- so the same
allocators, but instrumented.  (Because we hard-coded `free' already in
the printer, we know that this shouldn't break anything.)

That makes the `(factorial 100000)' test take twice as long to run (6
seconds vs 3 seconds), because GC ran 1000 times instead of 15 times,
but it kept the memory image size to 18 MB instead of 1800 MB.

Andy
-- 
http://wingolog.org/

Reply via email to