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

Not all finalized objects are untracked #19

Open
beta-ziliani opened this issue Jul 26, 2024 · 0 comments
Open

Not all finalized objects are untracked #19

beta-ziliani opened this issue Jul 26, 2024 · 0 comments

Comments

@beta-ziliani
Copy link
Member

beta-ziliani commented Jul 26, 2024

Likely this is expected behavior, but it should be documented then: not every freed object's memory is reclaimed, meaning that the untracking of objects does not match the finalizing of objects:

class Z
  @@deleted = Array(Int32).new(1000, 0)

  def initialize(@i : Int32)
  end

  def finalize
    @@deleted[@i] = 1
  end

  def self.deleted
    @@deleted.sum
  end
end

(0..1000).each { |i| Z.new i }
GC.collect
puts "Deleted: #{Z.deleted}" #=> 999
PerfTools::MemProf.log_object_counts(STDOUT) #=> ...\n 488	Z

In reality those 488 Z's are not live.

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