Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: memory usage and leakage

by Anonymous Monk
on Jun 23, 2011 at 11:41 UTC ( #911069=note: print w/replies, xml ) Need Help??


in reply to memory usage and leakage

Here is a win32 version, perl v5.12.2
#!/usr/bin/perl -- sub print_size { my ( $msg ) = @_; my @lines = qx{pslist -m $$ 2>NUL}; shift @lines for 1..3; chomp @lines; #~ print join "\n", @lines, ""; #~ Name Pid VM WS Priv Priv Pk Faults +NonP Page #~ perl 1052 25348 7220 4504 4512 1977 + 2 33 my %ps; @ps{'Name', 'Pid', 'VM', 'WS', 'Priv', 'Priv Pk', 'Faults', 'NonP', 'Page' } = grep length, split /\s+/, shift @lines; #~ Pri Priority #~ Thd Number of Threads #~ Hnd Number of Handles #~ VM Virtual Memory #~ WS Working Set ------ "Mem Usage" in taskmanager #~ Priv Private Virtual Memory ------ "VM Size" in taskman +ager #~ Priv Pk Private Virtual Memory Peak #~ Faults Page Faults #~ NonP Non-Paged Pool #~ Page Paged Pool #~ Cswtch Context Switches #~ use DDS; Dump(\@lines , \%ps); #~ print "VM: $ps{VM} RSS: $ps{WS} - $msg\n"; print "VM: $ps{VM} < WS: $ps{WS} VM: $ps{Priv} > $msg\n"; } BEGIN { print_size('empty'); } use strict; BEGIN { print_size('strict'); } use warnings; BEGIN { print_size('warnings'); } use Module::Load qw' load '; BEGIN { print_size('Module::Load'); } foreach my $module ( qw[ Module::Loaded Module::Pluggable Time::HiRes Time::Local Time::Piece Time::Seconds Time::gmtime Time::localtime Time::tm Pod::Perldoc Pod::Simple Data::Dumper Scalar::Util Getopt::Long LWP::UserAgent Moose ] ){ load $module; print_size($module); } load POE => qw(Component::Server::TCP); print_size("POE => qw(Component::Server::TCP)"); __END__
VM: 18660 < WS: 2756 VM: 608 > empty VM: 18660 < WS: 2956 VM: 636 > strict VM: 18660 < WS: 3092 VM: 760 > warnings VM: 18660 < WS: 3424 VM: 1024 > Module::Load VM: 18660 < WS: 3644 VM: 1216 > Module::Loaded VM: 20788 < WS: 4520 VM: 2036 > Module::Pluggable VM: 20972 < WS: 5084 VM: 2504 > Time::HiRes VM: 20972 < WS: 5168 VM: 2560 > Time::Local VM: 21020 < WS: 5556 VM: 2928 > Time::Piece VM: 21020 < WS: 5556 VM: 2928 > Time::Seconds VM: 21020 < WS: 5796 VM: 3172 > Time::gmtime VM: 21020 < WS: 5816 VM: 3184 > Time::localtime VM: 21020 < WS: 5816 VM: 3184 > Time::tm VM: 25152 < WS: 6544 VM: 3896 > Pod::Perldoc VM: 25152 < WS: 7660 VM: 4996 > Pod::Simple VM: 25220 < WS: 7996 VM: 5324 > Data::Dumper VM: 25220 < WS: 7996 VM: 5324 > Scalar::Util VM: 25220 < WS: 8404 VM: 5728 > Getopt::Long VM: 25352 < WS: 10188 VM: 7444 > LWP::UserAgent VM: 34232 < WS: 17548 VM: 14592 > Moose VM: 52272 < WS: 22800 VM: 19232 > POE => qw(Component::Server::TC +P)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://911069]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (10)
As of 2018-06-19 07:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (111 votes). Check out past polls.

    Notices?