How much Memory does my Ruby Script use ?

I could not find any in-ruby solution for this question, so here is a unix-solution.

def memory
  pid =
  map = `pmap -d #{pid}`


mapped: 17652K    writeable/private: 2180K    shared: 0K

Lesson learned
Use `open(file).each(seperator)` over `open(file).read.split(seperator)` if you want to optimize for memory (is slightly slower)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s