I've excluded dynamically loaded libraries from the root set in my program
I think it's safe, but if you know of anything that could go wrong, please
let me know.
My program runs on linux, osx and windows.
For Linux I've implemented the GC_register_has_static_roots_callback
Unfortunately, the callback is called for the main data segment as well,
the dynamic libraries, so I had to add some checks to identify whether to
return 0 or 1.
For OSX I had to do the same thing, but the way to identify whether we are
handling the main segment seems less flaky on OSX than on Linux.
For Windows, the GC_register_has_static_roots_callback callback is not
so instead I called 'GC_set_no_dls(1)', plus adding the main data segments
manually after calling 'GC_INIT()'.
Regarding the documentation, I think this line in include/gc.h:
"A filter function to control the scanning of dynamic libraries."
should be changed to
"A filter function to control the scanning of dynamic libraries and the
scanning of main program data segments"
or something similar.
On Fri, Jul 15, 2016 at 12:00 AM, Kjetil Matheussen <
Post by Kjetil Matheussen
I'm getting reports that my program sometimes stutter a little bit, and
that turning off the garbage collector fixes it.
So I thought I should try to minimize the root set by avoiding to load
the data segments of dynamically loaded libraries, since I know
that there are no root pointers there.
In gc.h, the most straight forward way seems to be calling
"In some environments like Microsoft Windows
and Apple's Darwin, this may also prevent
registration of the main data segment as part
of the root set"
This sounds a bit scary. Is this correct?
Perhaps it's better to implement the 'GC_has_static_roots_func'
callback, and always let it return 0?
Thanks for any help.