Don't scan for roots in dynamic libraries

This reduces the risk of object liveness misdetection. For example,
Glibc has an internal variable "mp_" that often points to a Boehm
object, keeping it alive unnecessarily. Since we don't store any
actual roots in global variables, we can just disable data segment
scanning.

With this, the max RSS doing 100 evaluations of
nixos.tests.firefox.x86_64-linux.drvPath went from 718 MiB to 455 MiB.
This commit is contained in:
Eelco Dolstra 2018-06-12 15:41:37 +02:00
parent 30964103dc
commit 455d1f01d0
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE

View file

@ -188,8 +188,15 @@ void initGC()
#if HAVE_BOEHMGC #if HAVE_BOEHMGC
/* Initialise the Boehm garbage collector. */ /* Initialise the Boehm garbage collector. */
/* Don't look for interior pointers. This reduces the odds of
misdetection a bit. */
GC_set_all_interior_pointers(0); GC_set_all_interior_pointers(0);
/* We don't have any roots in data segments, so don't scan from
there. */
GC_set_no_dls(1);
GC_INIT(); GC_INIT();
GC_set_oom_fn(oomHandler); GC_set_oom_fn(oomHandler);