Created
November 3, 2008 23:35
-
-
Save queso/22023 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}" | |
a = [] | |
b = [] | |
1000000.times { |n| a << n} | |
500000.times { |n| b << n} | |
puts "Memory before process: #{mem_usage}" | |
count.times do |n| | |
puts "Memory before process number #{n}: #{mem_usage}" | |
a - b | |
puts "Memory after process number #{n}: #{mem_usage}" | |
end | |
a = nil | |
b = nil | |
GC.start | |
puts "Memory on complete: #{mem_usage}" |
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
current process id is 14552 | |
Memory before anything: 1316 | |
Memory before process: 7240 | |
Memory before process number 0: 7240 | |
Memory after process number 0: 17644 | |
Memory before process number 1: 17644 | |
Memory after process number 1: 25596 | |
Memory before process number 2: 25596 | |
Memory after process number 2: 25596 | |
Memory before process number 3: 25596 | |
Memory after process number 3: 25596 | |
Memory before process number 4: 25596 | |
Memory after process number 4: 25596 | |
Memory on complete: 25080 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment