You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The push_keywords_obj (which is a TypedData object) has its data pointer set to NULL and is never freed, which leaks memory. The following script demonstrates the issue:
Before this patch, the output is 199620, after this patch, the output is 124160.
We shouldn't be using rb_gc_force_recycle anyways because it doesn't clean up resources and we should let the GC decide when to free objects (rather than forcing the GC to reclaim the object).
The push_keywords_obj (which is a TypedData object) has its data pointer set to NULL and is never freed, which leaks memory.
Good catch, I opened #158 as an alternative fix though.
We shouldn't be using rb_gc_force_recycle anyways because it doesn't clean up resources and we should let the GC decide when to free objects (rather than forcing the GC to reclaim the object).
It doesn't seem like that rb_gc_force_recycle is inherently bad (e.g. ruby uses it internally), but I had used it the wrong way. If I understand correctly, it doesn't require GC to reclaim the object, it is eagerly reclaiming the object so that it doesn't need GC to reclaim it.
@dylanahsmith While there are several places in Ruby that use rb_gc_force_recycle, the Ruby core team does not like it as it is difficult to maintain and makes changes in the GC difficult (e.g. ruby/ruby#4329 (comment))
Oh, apparently it is also "slow, now a day" according to the comment you linked to. Perhaps that is because it can't simply reuse objects with the current GC algorithm.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
push_keywords_obj(which is a TypedData object) has its data pointer set to NULL and is never freed, which leaks memory. The following script demonstrates the issue:Before this patch, the output is
199620, after this patch, the output is124160.We shouldn't be using
rb_gc_force_recycleanyways because it doesn't clean up resources and we should let the GC decide when to free objects (rather than forcing the GC to reclaim the object).