mirror of
https://github.com/jimeh/rbheap.git
synced 2026-02-19 04:46:40 +00:00
Add Ruby file that leaks memory and generates three heap dumps
Along with the dumps themselves, in a compressed bzip2 archive, as compression ratio was 30 to 1.
This commit is contained in:
BIN
test/heap-dumps.tar.bz2
Normal file
BIN
test/heap-dumps.tar.bz2
Normal file
Binary file not shown.
28
test/leak.rb
Normal file
28
test/leak.rb
Normal file
@@ -0,0 +1,28 @@
|
||||
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')
|
||||
Reference in New Issue
Block a user