Created
October 7, 2010 15:00
-
-
Save somebox/615231 to your computer and use it in GitHub Desktop.
track down memory bloat
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
# Report how much memory is being used right now | |
# and call it from different places to debug: | |
def report_memory(note) | |
memory_usage = `ps -o rss= -p #{$$}`.to_i | |
mem_mb = sprintf('%.2f MB', memory_usage/1000.0) | |
puts "mem [#{note}]: #{mem_mb}" | |
end | |
# To force ruby to do garbage collection: | |
GC.start | |
# remember that garbage cant be collected unless it's been freed. | |
@that_big_array = nil | |
that_var = nil | |
etc... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment