ActiveRecord objects in hashes aren't garbage collected — a bug or a sort of caching feature?

前端 未结 2 468
有刺的猬
有刺的猬 2021-01-30 07:14

I have a simple ActiveRecord model called Student with 100 records in the table. I do the following in a rails console session:

ObjectSpace.each_obj         


        
2条回答
  •  情深已故
    2021-01-30 08:01

    i do not know the answer

    But i tried inspecting the heap as given on http://blog.headius.com/2010/07/browsing-memory-jruby-way.html

    Have attached a screenshot at, https://skitch.com/deepak_kannan/en3dg/java-visualvm it was a simple program

    class Foo; end
    f1 = Foo.new
    f2 = Foo.new
    GC.start
    

    Then used jvisualvm as given above. Was running this in irb.
    Seems as if jruby is tracking the object's scope. The object will not get GC'ed if there are any non-weak references to that object

提交回复
热议问题