Create a gist now

Instantly share code, notes, and snippets.

How big is a Ruby thread? (a crude approximation on MRI/YARV on Linux)
1.9.3p194 :001 > base = Integer(`ps -o rss #{Process.pid}`[/\d+/])
=> 5748
1.9.3p194 :002 > Thread.new { sleep }
=> #<Thread:0x8db9d24 sleep>
1.9.3p194 :003 > Integer(`ps -o rss #{Process.pid}`[/\d+/]) - base
=> 20
From ps(1) on Linux:
The SIZE and RSS fields don't count some parts of a process including the page tables, kernel stack, struct thread_info, and struct task_struct. This
is usually at least 20 KiB of memory that is always resident. SIZE is the virtual size of the process (code+data+stack).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment