Last active
July 14, 2017 15:32
-
-
Save SamSaffron/859eec0c5a87c29f39c438471461e030 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def recurse(i) | |
recurse(i-1) if i > 0 | |
end | |
threads = ARGV[0].to_i | |
puts "Running with #{threads} threads!" | |
threads.times do | |
Thread.new do | |
recurse(500) | |
sleep | |
puts "done" | |
end | |
end | |
require 'memory_profiler' | |
MemoryProfiler.report do | |
Thread.new{sleep 0.1} | |
end.pretty_print | |
sleep 1 | |
puts "#{Thread.list.count} threads running!" | |
sleep |
Author
SamSaffron
commented
Apr 27, 2017
VSZ is is allocated, but only turns to RSS when used, you can see the impact via playing with recurse amount or setting stuff on thread storage.
So RSS impact depends on call stack depth and other stuff that is stored on the thread stack (local rvalues like numbers and params, thread local storage and so on)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment