Skip to content
This repository was archived by the owner on Apr 5, 2026. It is now read-only.
This repository was archived by the owner on Apr 5, 2026. It is now read-only.

Redlander objects not garbage collected when references falls out of scope #3

Description

@abargnesi

Redlander objects (i.e. Redlander::Model, Redlander::Statement, etc) define a finalizer to free up the corresponding C pointers, however the finalizer never seems to be called. The following snippet shows this symptom:

require 'redlander'
include Redlander

Model.new
puts "count after Model new: #{ObjectSpace.each_object(Model).count}"
# => count after Model new: 1
GC.start
puts "run garbage collector; full mark and sweep"
# => run garbage collector; full mark and sweep
ObjectSpace.each_object(Model).count
puts "count after GC: #{ObjectSpace.each_object(Model).count}"
# => count after GC: 1

Here the Model.new reference is not retained so the allocated object should be freed, however we see the same number of allocations of the Model object.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions