mirror of
https://github.com/jimeh/rbheap.git
synced 2026-02-19 04:46:40 +00:00
Along with the dumps themselves, in a compressed bzip2 archive, as compression ratio was 30 to 1.
29 lines
438 B
Ruby
29 lines
438 B
Ruby
require 'objspace'
|
|
|
|
class Leaky
|
|
def self.leak
|
|
@leak ||= []
|
|
end
|
|
|
|
def doit
|
|
noleak = []
|
|
|
|
50.times do
|
|
self.class.leak << 'leaked memory'
|
|
noleak << 'not leaked'
|
|
end
|
|
end
|
|
end
|
|
|
|
def dump_heap(filename)
|
|
GC.start
|
|
File.open(filename, 'w') { |file| ObjectSpace.dump_all(output: file) }
|
|
end
|
|
|
|
Leaky.new.doit
|
|
dump_heap('heap1.jsonl')
|
|
Leaky.new.doit
|
|
dump_heap('heap2.jsonl')
|
|
Leaky.new.doit
|
|
dump_heap('heap3.jsonl')
|