Created
November 4, 2008 00:30
-
-
Save queso/22040 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
def mem_usage | |
`ps -o rss= -p #{$$}`.to_i | |
end | |
@count = (ARGV[0] || 5).to_i | |
puts "current process id is #{$$}" | |
puts "Memory before anything: #{mem_usage}" | |
@array_a = [] | |
@array_b = [] | |
1000000.times { |n| @array_a << n} | |
500000.times { |n| @array_b << n} | |
def a | |
b | |
end | |
def b | |
c | |
end | |
def c | |
d | |
end | |
def d | |
e | |
end | |
def e | |
@count.times do |n| | |
puts "Memory before process number #{n}: #{mem_usage}" | |
@array_a - @array_b | |
puts "Memory after process number #{n}: #{mem_usage}" | |
end | |
end | |
puts "Memory before process: #{mem_usage}" | |
a | |
@array_a = nil | |
@array_b = nil | |
GC.start | |
puts "Memory on complete: #{mem_usage}" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment