Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7541729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:58:14+00:00 2026-05-30T07:58:14+00:00

I need to profile ruby gems memory usage. https://stackoverflow.com/a/164206/391229 suggests using system call to

  • 0

I need to profile ruby gems memory usage. https://stackoverflow.com/a/164206/391229 suggests using system call to measure memory footprint, so ended up with aliasing require method and gathering stats.

The top of the startup script (in my case it’s /usr/bin/padrino):

$memstat = {}
$memusage = `pmap #{Process.pid} | tail -1`[10,40].strip.to_i
$memstat['base'] = $memusage

alias :old_require :require
def require *args
  result = old_require *args
  oldmem = $memusage
  $memusage = `pmap #{Process.pid} | tail -1`[10,40].strip.to_i
  delta = $memusage - oldmem
  $memstat[args[0]] ||= 0
  $memstat[args[0]] += delta
  result
end

The event after loading everything (Padrino.after_load):

stat = $memstat.select{ |k,v| v>0 }.to_a.sort{ |a,b| a[1]<=>b[1] }
summ = 0
stat.each do |row|
  summ += row[1]
  puts "#{row[1].to_s.rjust(7)} KB: #{row[0]}"
end
puts summ.to_s.rjust(7) + ' KB'

The output I’m getting on invoking padrino console is:

        ...
   2120 KB: redcarpet.so
   2184 KB: socket.so
   2220 KB: etc
   2332 KB: addressable/idna/pure
   2740 KB: strscan
   2992 KB: haml/buffer
   3508 KB: pathname
   4240 KB: psych.so
   4252 KB: digest.so
   6028 KB: /home/ujif/swift/admin/app.rb
   6292 KB: zlib
   6704 KB: readline
   9116 KB: openssl.so
  12408 KB: do_mysql/do_mysql
  28164 KB: base
 145648 KB

Questions:

Is there any way to dig into base footprint?

Is there any cleaner approach to measure gems memory footprint on MRI ~> 1.9.2?

Any hints on improving my code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T07:58:15+00:00Added an answer on May 30, 2026 at 7:58 am

    Yep, it is the ruby stack. Try

    $ irb
    >> `pmap #{Process.pid} | tail -1`
    

    You got a similar result.

    Mine is: 144512K

    Instead if you run:

    $ ruby -e 'system "pmap #{Process.pid} | tail -1"'
    

    You a fewer value: 27788K (mine)

    So to inspect better what’s happen go back to irb

    $ irb
    >> puts `pmap #{Process.pid}`
    

    When you need to track padrino deps load your lib inside irb

    $ cd my_padrino_project
    $ irb -r /path/to/my/lib.rb
    >> require_relative 'config/boot'
    

    and check your results.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to profile an application compiled with intel's compiler via VC++. I'm using
I need to remotely profile a JVM for CPU Usage, IO stats and File
I need some help on creating a user profile system. I want it to
I need to profile the performance of an application for which I am using
I need to profile jetty server on linux system, for it I've started jetty
I am using the linkedin gem https://github.com/pengwynn/linkedin I authorize using Omniauth and store the
I need to profile a java application for a customer. It's an eclipse/maven project,
I need to profile my JAVA SRC code for some particular problem I am
We need to profile the JDBC operations of several web applications, number of queries,
I need to use a byte array as a profile property in a website.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.