Skip to content

Make obj_free unnecessary for common types #11

Open
@wks

Description

@wks

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions