Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
Possible bug with Ruby >= 2.7.0 and `GC.compact` #241
The new feature that helps with heap fragmentation,
Some objects are considered immovable, such as C classes and (perhaps) their instances. Also, any object referenced by a C extension using the
However, the Ruby GC is free to move the objects within the array to a new location (while updating the reference within the Ruby array).
Only C objects are immovable, but Ruby IO objects can be moved around since they aren't independently marked by
This means that whenever nio4r collects a reference to it's IO data structure (i.e., here and here), it is collecting a pointer that may have been moved (or some of the data within the data structure may point to an invalid pointer that was already moved).
I understand that creating an all-object GC mark data structure can be an expensive task, but there are many possible C implementations of the Set data structure, such as the one I implemented in iodine (extracted to the facio.io C STL repo and documented here.
All the code I pointed to for iodine and facil.io is MIT licensed. You're welcome to use it.
Let me know if I can help.
I think it might take me a week or two, since:
But I can play around and see what I can do... if the timeframe is fine.