Tim Bunce > Devel-SizeMe-0.020_080 > README

Download:
Devel-SizeMe-0.020_080.tar.gz

Annotate this POD

CPAN RT

Open  3
View/Report Bugs
Source   Latest Release: Devel-SizeMe-0.16

Devel::SizeMe - Perl extension for finding the memory usage of Perl variables

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 );

DESCRIPTION ^

Acts like Devel::Size 0.77 is 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::Size=: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

Build and Install ^

To build and install this module, you need:

     Perl
     a working C or C++ compiler
     a make (or namke on Windows) utility

Follow these steps:

On Linux, Cygwin, or Unix:

    perl Makefile.PL
    make
    make test
    sudo make install

On Windows:

    perl Makefile.PL
    nmake
    nmake test
    nmake install

BUGREPORTS ^

Please report bugs to:

    http://rt.cpan.org/NoAuth/Bugs.html?Dist=Devel-SizeMe

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.

TODO ^

Random notes...

Refactoring:

    Devel::SizeMe::Core - loads XS and sets options
    Devel::SizeMe - loads Devel::SizeMe::Core
        -d:SizeMe=opts?
    Devel::SizeMe::Stream - parse raw stream
    Devel::SizeMe::Store - db write
    Devel::SizeMe::Data - db read / orlite?
    Devel::SizeMe::Graph - data reading/processing for sizeme_graph
    sizeme_store - script wrapper for Devel::SizeMe::Store
    sizeme_graph - Mojolicious app wrapper using Devel::SizeMe::Graph
    tests!
    Support multiple runs to same sizeme_store process, generating separate files
    Name runs to allow total_size (for example) of multiple data structures

Issues:

    two cases where PERL_SUBVERSION is checked with a plain || (marked XXX)

Future

    Add addr to leaf to enable visualization of memory layout

    Add token for ptr to node already seen (identified by addr I presume)
        so we can move from a Tree to a DAG and see alternative name paths
        and reference loops
syntax highlighting: