Skip to content

Instantly share code, notes, and snippets.

@tarcieri
Created June 22, 2012 02:41
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save tarcieri/2969877 to your computer and use it in GitHub Desktop.
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