Looking for Memory Leaks in Sinatra Applications

February 26th, 2010

I like fixing things, so tracking down memory leaks and patching them is fun for me.

In the past I've done this using GTop in Aortica (a port of Nexista to Perl):

    my $mem = GTop->new->proc_mem($$)->share/1024;
    my $proc_mem = GTop->new->proc_mem($$)->size/1024;
    my $diff     = $proc_mem - $mem;
    my $shared   = GTop->new->proc_mem($$)->vsize/1024;
    my $memory = " Shared: ".$mem." Total: ".$proc_mem." PID: ".$$ ;

I can't find an exact match for GTop in Ruby, so I might just use the command line based top for now. I can use it to monitor a unicorn process id and watch if the memory it uses grows. It can even be run from within Sinatra:

get '/runtime/info' do
    `pmap #{} | tail -1`[10,40].strip


The "God" process monitor caught my attention. Its way more than I am looking for at the moment. It even looks like it might be able to replace how I'm using daemontools.

Yearly Indexes: 2003 2004 2006 2007 2008 2009 2010 2011 2012 2013 2015 2019 2020 2022