Skip to content

Instantly share code, notes, and snippets.



Created Jun 22, 2012
What would you like to do?
How big is a Ruby thread? (a crude approximation on MRI/YARV on Linux)
1.9.3p194 :001 > base = Integer(`ps -o rss #{}`[/\d+/])
=> 5748
1.9.3p194 :002 > { sleep }
=> #<Thread:0x8db9d24 sleep>
1.9.3p194 :003 > Integer(`ps -o rss #{}`[/\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