Devel::DumpSizes - Dump the name and size in bytes (in increasing order) of variables that are available at a give point in a script.


use Devel::DumpSizes qw/dump_sizes/;




This will print the name of each variable and its size. The name and size are seperated by a '->'

Variable name -> Size in bytes


Exports one subroutine by default:



This module allows us to print the names and sizes of variables that are available at a give point in a script.

This module was written while debugging a huge long running script. The main use being to understand how variable sizes were fluctuating during script execution. It uses PadWalker and Devel::Symdump to get the variables. It uses Devel::Size to report the size of each variable.



Usage: &Devel::DumpSizes::dump_sizes();


Usage: &Devel::DumpSizes::dump_sizes("/path/of/filename-to-dump-output");

This method accepts one optional parameter that will be used to create the file where the output is dumped.

If parameter is given then two files will be create. One will have extension .my and will contain my variables. The second file will have extension .ol and will contain our/local variables. If no filename is given output is printed on STDOUT.

As of now, the output is sectioned by printing the following at the start:

        1. either of 'my' or 'our/local' to specify the kind of variables being reported.

        2. output of time().

        3. If possible, subroutine name/line number as returned by caller (perldoc -f caller).

All sizes are in Bytes as returned by Devel::Size. I plan to have more information reported in newer versions.


  • The limitations of Devel::Size apply to this module.



Gautam Chekuri


Copyright (C) 2006 Chekuri Gatuam

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.