Open dinedal opened 11 years ago
Can you confirm that with the latest release are we all good?
I'm still seeing a leak. Is there a pointer that isn't being free'd?
This GC test is incorrect. The total_freed_object
count increases proportional to the total_allocated_object
count indicating that allocated objects are being collected.
Also keep in mind that GC.start will not execute a full mark and sweep unless you run GC.start(full_mark: true, immediate_sweep: true)
.
If you use ObjectSpace.count_objects
you can see proper garbage collection. Going further you can dump all objects using ObjectSpace.dump_all(output: open('heap.json', 'w'))
and you will see only a handle full of differences.
#!/usr/bin/env ruby
require 'leveldb'
require 'objspace'
db = LevelDB::DB.new("/tmp/leaktest")
GC.start(full_mark: true, immediate_sweep: true)
puts ObjectSpace.count_objects
# {
# :TOTAL=>92121,
# :FREE=>44550,
# :T_OBJECT=>4539,
# :T_CLASS=>1549,
# :T_MODULE=>88,
# :T_FLOAT=>6,
# :T_STRING=>25147,
# :T_REGEXP=>342,
# :T_ARRAY=>8794,
# :T_HASH=>387,
# :T_STRUCT=>34,
# :T_BIGNUM=>2,
# :T_FILE=>3,
# :T_DATA=>4074,
# :T_MATCH=>1,
# :T_COMPLEX=>1,
# :T_RATIONAL=>1,
# :T_NODE=>2469,
# :T_ICLASS=>134
# }
100000.times do
db.get('foo')
end
GC.start(full_mark: true, immediate_sweep: true)
puts ObjectSpace.count_objects
# {
# :TOTAL=>92121,
# :FREE=>44528,
# :T_OBJECT=>4539,
# :T_CLASS=>1549,
# :T_MODULE=>88,
# :T_FLOAT=>6,
# :T_STRING=>25171,
# :T_REGEXP=>341,
# :T_ARRAY=>8793,
# :T_HASH=>389,
# :T_STRUCT=>34,
# :T_BIGNUM=>2,
# :T_FILE=>3,
# :T_DATA=>4074,
# :T_MATCH=>1,
# :T_COMPLEX=>1,
# :T_RATIONAL=>1,
# :T_NODE=>2467,
# :T_ICLASS=>134
# }
Sample output:
Just for db.get on a nonexistant key 10,000 times, looks like there were 160024 allocated objects that can not get freed