Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make obj_free unnecessary for common types #11

Open
wks opened this issue Aug 30, 2022 · 0 comments
Open

Make obj_free unnecessary for common types #11

wks opened this issue Aug 30, 2022 · 0 comments

Comments

@wks
Copy link
Collaborator

wks commented Aug 30, 2022

This is related to #10, but more general

In vanilla Ruby, obj_free is necessary for most types. In most cases, it frees the underlying off-heap buffers of large data structures, including T_OBJECT, T_STRING, T_ARRAY, T_HASH, T_BIGNUM, T_STRUCT, etc. Those off-heap buffers should be reimplemented using GC-traced on-heap objects. By doing so, no finalisation is necessary for those types, as the memory is totally managed by the GC. See #10

Other types may still need finalisation, but we can use non-resurrecting finaliser, instead. Ruby's ObjectSpace.define_finalizer already uses non-resurrecting finalisation.

  • T_DATA: user-defined types.
  • T_REGEXP: Regular expression using third-party library "Oniguruma".
  • other types.

Maybe we can use non-resurrecting finalisation instead, but only if the pointer field that points to native structure never changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant