From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 35681BC57 for ; Mon, 30 Aug 2010 15:53:46 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ah4GAE5Ve0xQRFuwWWdsb2JhbACgRQsBFhUENrpphTcE X-IronPort-AV: E=Sophos;i="4.56,292,1280700000"; d="scan'208";a="66309151" Received: from furbychan.cocan.org ([80.68.91.176]) by mail1-smtp-roc.national.inria.fr with ESMTP; 30 Aug 2010 15:53:45 +0200 Received: from rich by furbychan.cocan.org with local (Exim 4.63) (envelope-from ) id 1Oq4nw-0006Xz-Ry; Mon, 30 Aug 2010 14:53:44 +0100 Date: Mon, 30 Aug 2010 14:53:44 +0100 To: Hugo Ferreira Cc: caml-list@inria.fr Subject: Re: [Caml-list] Tracking memory usage: GC output not same order as unix top command Message-ID: <20100830135344.GC7715@annexia.org> References: <4C7B7D4E.4020500@inescporto.pt> <20100830100252.GA7715@annexia.org> <20100830100648.GB7715@annexia.org> <4C7B890C.7090704@inescporto.pt> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4C7B890C.7090704@inescporto.pt> User-Agent: Mutt/1.5.13 (2006-08-11) From: Richard Jones X-Spam: no; 0.00; 0100,:01 usr:01 argv:01 printf:01 printf:01 -wt:98 wrote:01 wrote:01 unix:01 rec:01 rec:01 readable:01 caml-list:01 bin:01 exp:02 On Mon, Aug 30, 2010 at 11:33:48AM +0100, Hugo Ferreira wrote: > I looked at this tool. Going to ask the admin if he can install > this because I cannot interpret the output from the "/proc//maps". Here's a Perl script that I wrote quite a long time ago. I don't know if it still works, but worth looking at. Rich. ---------------------------------------------------------------------- #!/usr/bin/perl -wT # Parse /proc/*/maps file into a readable summary. # $Id: maps.pl,v 1.1 2006/11/01 10:35:56 rich Exp $ no warnings qw(portable); foreach my $filename (@ARGV) { my %devices; open MAPS, "<$filename" or die "$filename: $!"; while () { if (m/^([[:xdigit:]]+)-([[:xdigit:]]+) ([-rwxps]+) ([[:xdigit:]]+) ([[:xdigit:]]{2}:[[:xdigit:]]{2}) (\d+)\s*(.*)?/) { my $start = hex $1; my $end = hex $2; my $perms = $3; my $offset = hex $4; my $device = $5; my $inode = $6; my $filename = $7; my $size = $end - $start; # Create a record. my %rec = ( start => $start, end => $end, perms => $perms, offset => $offset, device => $device, inode => $inode, filename => $filename, size => $size ); # Key for storing this. my $key; if ($device ne "00:00" && $inode != 0) { $key = "$filename ($device $inode)" } elsif ($filename ne "") { $key = $filename } else { $key = "anonymous mapping" } # Store it. $devices{$key} = [] if !exists $devices{$key}; push @{$devices{$key}}, \%rec } else { warn "ignored: $_\n" } } close MAPS; # Get the list of devices. my @devices = keys %devices; # For each device, print a summary. foreach (@devices) { print "$_:\n"; my @recs = @{$devices{$_}}; my $sum = 0; $sum += $_->{size} foreach @recs; printf (" %d bytes %.1f MB\n", $sum, $sum/1024/1024); print " segments:\n"; foreach (@recs) { printf (" %x-%x (%d bytes %.1f MB) %s %d\n", $_->{start}, $_->{end}, $_->{size}, $_->{size}/1024/1024, $_->{perms}, $_->{offset}); } } } ---------------------------------------------------------------------- -- Richard Jones Red Hat