Commit | Line | Data |
e98cedbf |
1 | package Devel::Size; |
2 | |
e98cedbf |
3 | use strict; |
a6ea0805 |
4 | use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $AUTOLOAD %EXPORT_TAGS); |
e98cedbf |
5 | |
6 | require Exporter; |
7 | require DynaLoader; |
8 | |
a6ea0805 |
9 | @ISA = qw(Exporter DynaLoader); |
e98cedbf |
10 | |
11 | # Items to export into callers namespace by default. Note: do not export |
12 | # names by default without a very good reason. Use EXPORT_OK instead. |
13 | # Do not simply export all your public functions/methods/constants. |
14 | |
15 | # This allows declaration use Devel::Size ':all'; |
16 | # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK |
17 | # will save memory. |
a6ea0805 |
18 | %EXPORT_TAGS = ( 'all' => [ qw( |
6a9ad7ec |
19 | size, total_size |
e98cedbf |
20 | ) ] ); |
21 | |
a6ea0805 |
22 | @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
e98cedbf |
23 | |
a6ea0805 |
24 | @EXPORT = qw( |
e98cedbf |
25 | |
26 | ); |
5c2e1b12 |
27 | $VERSION = '0.52'; |
e98cedbf |
28 | |
29 | bootstrap Devel::Size $VERSION; |
30 | |
31 | # Preloaded methods go here. |
32 | |
33 | 1; |
34 | __END__ |
35 | # Below is stub documentation for your module. You better edit it! |
36 | |
37 | =head1 NAME |
38 | |
39 | Devel::Size - Perl extension for finding the memory usage of perl variables |
40 | |
41 | =head1 SYNOPSIS |
42 | |
43 | use Devel::Size qw(size); |
44 | $size = size("abcde"); |
45 | $other_size = size(\@foo); |
46 | |
5c2e1b12 |
47 | $foo = {a => [1, 2, 3], |
48 | b => {a => [1, 3, 4]} |
49 | }; |
50 | $total_size = total_size($foo); |
51 | |
e98cedbf |
52 | =head1 DESCRIPTION |
53 | |
54 | This module figures out the real sizes of perl variables. Call it with |
55 | a reference to the variable you want the size of. If you pass in a |
56 | plain scalar it returns the size of that scalar. (Just be careful if |
57 | you're asking for the size of a reference, as it'll follow the |
58 | reference if you don't reference it first) |
59 | |
5c2e1b12 |
60 | The C<size> function returns the amount of memory the variable |
61 | uses. If the variable is a hash or array, it only reports the amount |
62 | used by the variable structure, I<not> the contents. |
63 | |
64 | The C<total_size> function will walk the variable and look at the |
65 | sizes of the contents. If the variable contains references those |
66 | references will be walked, so if you have a multidimensional data |
67 | structure you'll get the total structure size. (There isn't, at the |
68 | moment, a way to get the size of an array or hash and its elements |
69 | without a full walk) |
70 | |
e98cedbf |
71 | =head2 EXPORT |
72 | |
73 | None by default. |
74 | |
75 | =head1 BUGS |
76 | |
6a9ad7ec |
77 | Doesn't currently walk all the bits for code refs, globs, formats, and |
78 | IO. Those throw a warning, but a minimum size for them is returned. |
e98cedbf |
79 | |
e98cedbf |
80 | =head1 AUTHOR |
81 | |
82 | Dan Sugalski dan@sidhe.org |
83 | |
84 | =head1 SEE ALSO |
85 | |
86 | perl(1). |
87 | |
88 | =cut |