Closed p0nce closed 5 years ago
Title would be something like "Forcing the GC to be less conservative", "Wrestling with false pointers", "Conservative GCs hate this trick!"
More ketmar tricks:
<ketmar> but if you'll slice such array, slice won't anchor it too. so if there is no pointer to array's head... BOOM! segfault or memory corruption
<ketmar> it is not about scanning a block. it is about deciding if the found pointer points to that block or not
<ketmar> if you have 50MB block, any pointer inside those 50MB will prevent collecting. with NO_INTERIOR, only pointer to the first byte of the block will
<ketmar> i mean, anything outside the block that *looks* like a pointer to it
<ketmar> that is, suddenly, you have to do precision shots with pointers, and that decreases falst positives to almost zero
<ketmar> but then you have to manage lifetime of array slices manually
<p0nce> thanks for the explanation. That sounds similar to a malloc area? you can slice it if you manage the lifetimes properly
<ketmar> yeah. almost the same, but without manual `free()` -- GC is still responsible for alloced mem. only it can collect it sooner than you expecting ;-)
NO_INTERIOR is used as an intermediate between regular GC code and "manual memory management", still leaving free() to the GC if you manage lifetimes correctly.
Not an issue anymore with recent GC