Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^3: memory usage of modules

by shmem (Chancellor)
on Nov 23, 2009 at 20:08 UTC ( [id://808915]=note: print w/replies, xml ) Need Help??


in reply to Re^2: memory usage of modules
in thread memory usage of modules

Ah well ;-) GTop... this Module also has the advantage that you can query any kind of size, and you get it in bytes. Voilà:

package MemImpact::GTop; use strict; use GTop; my @meths = qw(size vsize rss share); my $before = GTop->new->proc_mem($$); my $after = my $now = $before; printf "%-60s % 10d Bytes\n", "$_ initial memory:" , $before->$_ for @meths; print "-" x 77, $/; sub import { my $pack = shift; my $meth = shift; for (@_) { eval "use $_;"; die "Can't load $_:\n$@\n" if $@; $after = GTop->new->proc_mem($$); printf "%-60s % 10d Bytes\n", "$meth after loading $_:" , $aft +er->$meth; printf "%-60s % 10d Bytes\n", "$meth impact of $_:" , $after-> +$meth - $now->$meth; $now = $after; } } END { print "-" x 77, $/; printf "%-60s % 10d Bytes\n", "$_ total impact:" , $after->$_ - $b +efore->$_ for @meths; } 1;
qwurx [shmem] ~ > perl -e 'use MemImpact::GTop qw(rss Moose); use MemI +mpact::GTop qw(rss MooseX::AttributeHelpers)' size initial memory: 934707 +2 Bytes vsize initial memory: 934707 +2 Bytes rss initial memory: 346112 +0 Bytes share initial memory: 250265 +6 Bytes ---------------------------------------------------------------------- +------- rss after loading Moose: 897433 +6 Bytes rss impact of Moose: 551321 +6 Bytes rss after loading MooseX::AttributeHelpers: 1043660 +8 Bytes rss impact of MooseX::AttributeHelpers: 146227 +2 Bytes ---------------------------------------------------------------------- +------- size total impact: 711065 +6 Bytes vsize total impact: 711065 +6 Bytes rss total impact: 697548 +8 Bytes share total impact: 35225 +6 Bytes

Replies are listed 'Best First'.
Re^4: memory usage of modules
by BioLion (Curate) on Nov 24, 2009 at 11:28 UTC

    ++! thanks guys, I'll have a look into these (how did this end up as my question!?). I often find a need for checking that i am not about to crash my computer (lots of data, rubbish computer - go figure!).

    Just a something something...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://808915]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-04-20 01:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found