MYMETA.yml
Makefile
Makefile.old
-Memory.[co]
-Memory.bs
+SizeMe.[co]
+SizeMe.bs
Revision history for Perl extension Devel::Memory.
+0.02 2012-10-02 Tim Bunce
+
+ * Renamed to Devel::SizeMe.
+ * Assorted fixes, cleanups and polish.
+
0.01 2012-09-29 Tim Bunce
* Created new Devel::Memory extension using a modified version of
CHANGES
-lib/Devel/Memory.pm
+lib/Devel/SizeMe.pm
Makefile.PL
MANIFEST
MANIFEST.SKIP
META.yml Module meta-data (added by MakeMaker)
README
-Memory.xs
+SizeMe.xs
ppport.h
t/basic.t
t/code.t
#
# command.
#
-^Devel-Memory.*\.tar\.gz
+^Devel-SizeMe.*\.tar\.gz
^Makefile.old
^Makefile\z
^pm_to_blib
^MANIFEST.(bak|old)
-^Memory.(c|o|bs)
+^SizeMe.(c|o|bs)
^blib.*
tmon.out
\.txt\z
WriteMakefile(
OPTIMIZE => "-g",
- NAME => 'Devel::Memory',
- VERSION_FROM => 'lib/Devel/Memory.pm',
+ NAME => 'Devel::SizeMe',
+ VERSION_FROM => 'lib/Devel/SizeMe.pm',
DEFINE => "-DALIGN_BITS=$ptr_bits",
PREREQ_PM => {
'Test::More' => 0,
TODO
- Rename to Devel::SizeMe
Devel::SizeMe::Core - loads XS and sets options
Devel::SizeMe - loads XS
-d:SizeMe=opts
=pod
-Devel::Memory - Perl extension for finding the memory usage of Perl variables
+Devel::SizeMe - Perl extension for finding the memory usage of Perl variables
=head1 SYNOPSIS
- use Devel::Memory qw(size total_size);
+ use Devel::SizeMe qw(size total_size);
my $size = size("A string");
my @foo = (1, 2, 3, 4, 5);
Please report bugs to:
- http://rt.cpan.org/NoAuth/Bugs.html?Dist=Devel-Memory
+ http://rt.cpan.org/NoAuth/Bugs.html?Dist=Devel-SizeMe
=head1 COPYRIGHT
-Copyright (C) 2005 Dan Sugalski, Copyright (C) 2007-2008 Tels,
-Copyright (C) 2011-2012 Nicholas Clark, Copyright 2012 (C) Tim Bunce.
+Copyright (C) 2005 Dan Sugalski,
+Copyright (C) 2007-2008 Tels,
+Copyright (C) 2008 BrowserUK,
+Copyright (C) 2011-2012 Nicholas Clark,
+Copyright (C) 2012 Tim Bunce.
This module is free software; you can redistribute it and/or modify it
under the same terms as Perl v5.8.8.
}
-MODULE = Devel::Memory PACKAGE = Devel::Memory
+MODULE = Devel::SizeMe PACKAGE = Devel::SizeMe
PROTOTYPES: DISABLE
if ($x->{name} eq 'AVelem' and $parent->{name} eq 'SV(PVAV)') {
my $index = $x->{attr}{+NPattr_NOTE}{i};
- Dwarn $x->{attr};
- Dwarn $index;
+ #Dwarn $x->{attr};
+ #Dwarn $index;
# If node is an AVelem of a CvPADLIST propagate pad name to AVelem
if (@stack >= 4 and (my $cvpl = $stack[-4])->{name} eq 'CvPADLIST') {
my $padnames = $cvpl->{_cached}{padnames} ||= do {
warn "Node $id already has attribute $type:$name (value $attr->{$type}{$name})\n"
if exists $attr->{$type}{$name};
$attr->{$type}{$name} = $val;
- Dwarn $attr;
+ #Dwarn $attr;
$node->{title} = $name if $type == NPattr_NAME and !$val; # XXX hack
}
# attributes where the number is a key (or always zero)
my $top = $stack[0]; # grab top node before we pop all the nodes
leave_node(pop @stack) while @stack;
+ # if nothing output (ie size(undef))
+ $top ||= { self_size=>0, kids_size=>0, kids_node_count=>0 };
+
my $top_size = $top->{self_size}+$top->{kids_size};
- printf "Stored %d nodes (${.}n) sizing %s (%d) in %.2fs\n",
- $top->{kids_node_count}, fmt_size($top_size), $top_size,
- $val;
+ printf "Stored %d nodes totalling %s [lines=%d size=%d write=%.2fs]\n",
+ 1+$top->{kids_node_count}, fmt_size($top_size),
+ $., $top_size, $val;
# the duration here ($val) is from Devel::SizeMe perspective
# ie doesn't include time to read file/pipe and commit to database.
+++ /dev/null
-package Devel::Memory;
-
-use strict;
-use vars qw($VERSION @ISA @EXPORT_OK %EXPORT_TAGS $warn $dangle);
-
-require 5.005;
-require Exporter;
-require XSLoader;
-
-@ISA = qw(Exporter);
-
-@EXPORT_OK = qw(size total_size perl_size);
-
-# This allows declaration use Devel::Memory ':all';
-%EXPORT_TAGS = ( 'all' => \@EXPORT_OK );
-
-$VERSION = '0.01';
-
-XSLoader::load( __PACKAGE__);
-
-$warn = 1;
-$dangle = 0; ## Set true to enable warnings about dangling pointers
-
-1;
-__END__
-
-=pod
-
-Devel::Memory - Perl extension for finding the memory usage of Perl variables
-
-=head1 SYNOPSIS
-
- use Devel::Memory qw(size total_size);
-
- my $size = size("A string");
- my @foo = (1, 2, 3, 4, 5);
- my $other_size = size(\@foo);
- my $total_size = total_size( $ref_to_data );
-
-=head1 DESCRIPTION
-
-Acts like Devel::Size 0.77 if the PERL_DMEM env var is not set.
-
-Except that it also provides perl_size() and heap_size() functions.
-
-If PERL_DMEM env var is set to an empty string then all the *_size functions
-dump a textual representation of the memory data to stderr.
-
-If PERL_DMEM env var is set to a string that starts with "|" then the
-remainder of the string is taken to be a command name and popen() is used to
-start the command and the raw memory data is piped to it.
-
-If PERL_DMEM env var is set to anything else it is treated as the name of a
-file the raw memory data should be written to.
-
-The dmemtree.pl script can be used to process the raw memory data.
-Typically run via the PERL_DMEM env var. For example:
-
- export PERL_DMEM='|./dmemtree.pl --text'
- export PERL_DMEM='|./dmemtree.pl --dot=dmemtree.dot'
- export PERL_DMEM='|./dmemtree.pl --db=dmemtree.db'
-
-The --text output is similar to the textual representation output by the module
-when the PERL_DMEM env var is set to an empty string.
-
-The --dot output is suitable for feeding to Graphviz.
-
-The --db output is a SQLite database. (Very subject to change.)
-
-Example usage:
-
- PERL_DMEM='|dmemtree.pl --db=dmemtree.db' perl -MDevel::Memory=:all -e 'total_size(sub { })'
-
-The dmemview.pl script is a Mojolicious::Lite application that serves data to
-an interactive treemap visualization of the memory use. It can be run as:
-
- dmemview.pl daemon
-
-and then open http://127.0.0.1:3000
-
-Please report bugs to:
-
- http://rt.cpan.org/NoAuth/Bugs.html?Dist=Devel-Memory
-
-=head1 COPYRIGHT
-
-Copyright (C) 2005 Dan Sugalski,
-Copyright (C) 2007-2008 Tels,
-Copyright (C) BrowserUK 2008,
-Copyright (C) 2011-2012 Nicholas Clark,
-Copyright (C) 2012 Tim Bunce.
-
-This module is free software; you can redistribute it and/or modify it
-under the same terms as Perl v5.8.8.
-
-=head1 SEE ALSO
-
-perl(1), L<Devel::Size>.
-
-=cut
package Devel::SizeMe;
-require Devel::Memory;
-
-my $gz = (0) ? "gzip -c | gzip -dc |" : ""; # currently saves ~3%
-$ENV{SIZEME} = "| $gz sizeme_store.pl -d --text --dot=sizeme.dot --showid --db=sizeme.db";
-
-my $do_size_at_end = 0; # set true below for "perl -d:SizeMe ..."
-
-# It's handy to say "perl -d:SizeMe" but has side effects
-# currently we simple disable the debugger (as best we can)
-# otherwise it (or rather some bits of $^P) cause memory bloat.
-# we might want to provide some smarter compatibility in future.
-# We might also want to provide a way to set some bits, such as
-# 0x10 Keep info about source lines on which a sub is defined
-# 0x100 Provide informative "file" names for evals
-# 0x200 Provide informative names to anonymous subroutines
-if ($^P) { # default is 0x73f
- warn "Note: Devel::SizeMe currently disables perl debugger mode\n";
- $^P = 0;
- $do_size_at_end = 1;
+# As a handy convenience, make perl -d:SizeMe automatically call heap_size
+# in an END block, and also set some $^P flags to get more detail.
+my $do_size_at_end; # set true below for "perl -d:SizeMe ..."
+BEGIN {
+ if ($^P) {
+ warn "Note: Devel::SizeMe currently disables perl debugger mode\n";
+ warn scalar keys %INC;
+ # default $^P set by "perl -d" is 0x73f
+ $^P = 0x10 # Keep info about source lines on which a sub is defined
+ | 0x100 # Provide informative "file" names for evals
+ | 0x200 # Provide informative names to anonymous subroutines;
+ ;
+ $do_size_at_end = 1;
+ }
}
+use strict;
+use vars qw($VERSION @ISA @EXPORT_OK %EXPORT_TAGS $warn $dangle);
+
+require 5.005;
+require Exporter;
+require XSLoader;
+
+$VERSION = '0.02';
+@ISA = qw(Exporter);
+
+@EXPORT_OK = qw(size total_size perl_size heap_size);
+%EXPORT_TAGS = ( 'all' => \@EXPORT_OK ); # for use Devel::SizeMe ':all';
+
+$warn = 1;
+$dangle = 0; ## Set true to enable warnings about dangling pointers
+
+$ENV{SIZEME} ||= "| sizeme_store.pl --showid --db=sizeme.db";
+
+XSLoader::load( __PACKAGE__);
+
END {
- Devel::Memory::perl_size() if $do_size_at_end;
+ Devel::SizeMe::perl_size() if $do_size_at_end;
}
1;
+__END__
+
+=pod
+
+Devel::SizeMe - Perl extension for finding the memory usage of Perl variables
+
+=head1 SYNOPSIS
+
+ use Devel::SizeMe qw(size total_size);
+
+ my $size = size("A string");
+ my @foo = (1, 2, 3, 4, 5);
+ my $other_size = size(\@foo);
+ my $total_size = total_size( $ref_to_data );
+
+=head1 DESCRIPTION
+
+Acts like Devel::Size 0.77 if the SIZEME env var is not set.
+
+Except that it also provides perl_size() and heap_size() functions.
+
+If SIZEME env var is set to an empty string then all the *_size functions
+dump a textual representation of the memory data to stderr.
+
+If SIZEME env var is set to a string that starts with "|" then the
+remainder of the string is taken to be a command name and popen() is used to
+start the command and the raw memory data is piped to it.
+
+If SIZEME env var is set to anything else it is treated as the name of a
+file the raw memory data should be written to.
+
+The sizeme_store.pl script can be used to process the raw memory data.
+Typically run via the SIZEME env var. For example:
+
+ export SIZEME='|./sizeme_store.pl --text'
+ export SIZEME='|./sizeme_store.pl --dot=sizeme.dot'
+ export SIZEME='|./sizeme_store.pl --db=sizeme.db'
+
+The --text output is similar to the textual representation output by the module
+when the SIZEME env var is set to an empty string.
+
+The --dot output is suitable for feeding to Graphviz.
+
+The --db output is a SQLite database. (Very subject to change.)
+
+Example usage:
+
+ SIZEME='|sizeme_store.pl --db=sizeme.db' perl -MDevel::SizeMe=:all -e 'total_size(sub { })'
+
+The sizeme_graph.pl script is a Mojolicious::Lite application that serves data to
+an interactive treemap visualization of the memory use. It can be run as:
+
+ sizeme_graph.pl daemon
+
+and then open http://127.0.0.1:3000
+
+Please report bugs to:
+
+ http://rt.cpan.org/NoAuth/Bugs.html?Dist=Devel-SizeMe
+
+=head1 COPYRIGHT
+
+Copyright (C) 2005 Dan Sugalski,
+Copyright (C) 2007-2008 Tels,
+Copyright (C) 2008 BrowserUK,
+Copyright (C) 2011-2012 Nicholas Clark,
+Copyright (C) 2012 Tim Bunce.
+
+This module is free software; you can redistribute it and/or modify it
+under the same terms as Perl v5.8.8.
+
+=head1 SEE ALSO
+
+perl(1), L<Devel::Size>.
+
+=cut
use Test::More tests => 30;
use strict;
-use Devel::Memory qw(size total_size);
+use Devel::SizeMe qw(size total_size);
-can_ok ('Devel::Memory', qw/
+can_ok ('Devel::SizeMe', qw/
size
total_size
/);
-die ("Uhoh, test uses an outdated version of Devel::Memory")
- unless is ($Devel::Memory::VERSION, '0.01', 'VERSION MATCHES');
+die ("Uhoh, test uses an outdated version of Devel::SizeMe")
+ unless is ($Devel::SizeMe::VERSION, '0.02', 'VERSION MATCHES');
#############################################################################
# some basic checks:
use strict;
use Test::More tests => 12;
-use Devel::Memory ':all';
+use Devel::SizeMe ':all';
sub zwapp;
sub swoosh($$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$);
use strict;
use Test::More tests => 44;
-use Devel::Memory ':all';
+use Devel::SizeMe ':all';
use Config;
my $warn_count;
gv_grew('clange', 'sock', 'no strict "vars"; %sock = (); 1', 'HASH');
SKIP: {
skip("Can't create FORMAT references prior to 5.8.0", 7) if $] < 5.008;
- local $Devel::Memory::warn = 0;
+ local $Devel::SizeMe::warn = 0;
gv_grew('biff', 'zapeth', "format zapeth =\n.\n1", 'FORMAT');
}
gv_grew('crunch_eth', 'awkkkkkk', 'sub awkkkkkk {}; 1', 'CODE');
-# Devel::Memory isn't even tracking PVIOs from GVs (yet)
+# Devel::SizeMe isn't even tracking PVIOs from GVs (yet)
# gv_grew('kapow', 'thwape', 'opendir *thwape, "."', 'IO');
is($warn_count, undef, 'No warnings emitted');
use strict;
use Test::More tests => 18;
-use Devel::Memory ':all';
+use Devel::SizeMe ':all';
require Tie::Scalar;
{
eval "use Test::Pod;";
$@ ? 0 : 1;
};
- pod_file_ok( '../lib/Devel/Memory.pm' );
+ pod_file_ok( '../lib/Devel/SizeMe.pm' );
}
$@ ? 0 : 1;
};
for my $m (qw/
- Devel::Memory
+ Devel::SizeMe
/)
{
pod_coverage_ok( $m, "$m is covered" );
use strict;
use Test::More tests => 2;
-use Devel::Memory ':all';
+use Devel::SizeMe ':all';
use Config;
use constant PVBM => 'galumphing';
use Test::More;
use strict;
-use Devel::Memory ':all';
+use Devel::SizeMe ':all';
my %types = (
NULL => undef,