On Tue 31 Oct 2017 00:13, ludo@gnu.org (Ludovic Courtès) writes: > I built libguile with the patch (I haven’t yet taken the time to rebuild > all of Guile). It works, but unfortunately it still shows quick growth > of the heap on this example (): Fixed in attached patches (on top of the other one). This was a race between the periodic vacuum process, which should run after GC via a finalizer, and the mutator. If the mutator had the weak table lock, the vacuum would never be run. Of course in the test below, the mutator usually has the table lock, so we ended up often skipping the vacuum, which causes the table size to grow, which causes the active heap size to grow, which causes the bytes-allocated-before-GC to increase, and which ultimately is a vicious circle. In my tests this patch fixes the issue, though the level at which the heap stabilizes can vary slightly as there's a bit of nondeterministic concurrency as the mutator and the vacuum process still race a bit. Right now for me it stabilizes at about 6.2M of heap. >> weak_key_gc_kind = >> GC_new_kind (GC_new_free_list (), >> - GC_MAKE_PROC (GC_new_proc (mark_weak_key_table), 0), >> + GC_MAKE_PROC (GC_new_proc (mark_weak_key_entry), 0), >> 0, 0); > > I think we should avoid custom mark procedures and use a bitmap here, as > recommended in the libgc headers (like ‘wcar_pair_descr’ in weaks.c in > 2.0.) Good idea; fixed. Andy