Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: 4024aa1047
Fetching contributors…

Cannot retrieve contributors at this time

30 lines (25 sloc) 0.688 kb
require File.expand_path('helper', File.dirname(__FILE__))
class TestMemoryLeaks < Test::Unit::TestCase
include Examples
def test_memory_prof
5.times do
1000.times do |i|
brief_example
end
change = change_to_real_memory_in_kb
assert (change < 10000), "memory leak #{change}kb"
end
end
def real_memory_in_kb
# "=" after "rss" strips the header line.
`ps -p #{Process.pid} -o rss=`.to_i
end
def change_to_real_memory_in_kb
GC.start
r = real_memory_in_kb
@change_to_real_memory_in_kb__prev ||= r
r - @change_to_real_memory_in_kb__prev
ensure
@change_to_real_memory_in_kb__prev = r
end
end
Jump to Line
Something went wrong with that request. Please try again.