0.58 Fri Jul 18 11:42:32 2003
- Fix for problems triggered by perl 5.8.0 and up, more tests, and
removal of an "our" for better backwards compatibility. (Courtesy
- of Marcus Holland-Moritz <mhx-perl@gmx.net>)
\ No newline at end of file
+ of Marcus Holland-Moritz <mhx-perl@gmx.net>)
+
+0.59 Sat Nov 27 16:42:42 2004
+ - Applied documentation and sane warning patch from Nigel Sandever
+ - Taught Devel::Size how to size up IO and globs properly
@EXPORT = qw(
);
-$VERSION = '0.58';
+$VERSION = '0.59';
bootstrap Devel::Size $VERSION;
memory is released at the end, but it may fragment your free pool,
and will definitely expand your process' memory footprint.
+=head1 Messages: texts originating from this module.
+
+=head2 Errors
+
+=over 4
+
+=item "Devel::Size: Unknown variable type"
+
+The thing (or something contained within it) that you gave to
+total_size() was unrecognisable as a Perl entity.
+
+=back
+
+=head2 warnings
+
+These messages warn you that for some types, the sizes calculated may not include
+everything that could be associated with those types. The differences are usually
+insignificant for most uses of this module.
+
+These may be disabled by setting
+
+ $Devel::Size::warn = 0
+
+=over 4
+
+=item "Devel::Size: Calculated sizes for CVs are incomplete"
+
+=item "Devel::Size: Calculated sizes for FMs are incomplete"
+
+=item "Devel::Size: Calculated sizes for IOs are incomplete"
+
+=back
+
=head1 BUGS
Doesn't currently walk all the bits for code refs, formats, and
total_size += sizeof(XPVCV);
total_size += magic_size(thing, tracking_hash);
if (go_yell) {
- carp("CV isn't complete");
+ carp("Devel::Size: Calculated sizes for CVs are incomplete");
}
break;
case SVt_PVGV:
if (GvGP(thing)) {
if (check_new(tracking_hash, GvGP(thing))) {
total_size += sizeof(GP);
+ {
+ SV *generic_thing;
+ if (generic_thing = (SV *)(GvGP(thing)->gp_sv)) {
+ total_size += thing_size(generic_thing, tracking_hash);
+ }
+ if (generic_thing = (SV *)(GvGP(thing)->gp_form)) {
+ total_size += thing_size(generic_thing, tracking_hash);
+ }
+ if (generic_thing = (SV *)(GvGP(thing)->gp_av)) {
+ total_size += thing_size(generic_thing, tracking_hash);
+ }
+ if (generic_thing = (SV *)(GvGP(thing)->gp_hv)) {
+ total_size += thing_size(generic_thing, tracking_hash);
+ }
+ if (generic_thing = (SV *)(GvGP(thing)->gp_egv)) {
+ total_size += thing_size(generic_thing, tracking_hash);
+ }
+ if (generic_thing = (SV *)(GvGP(thing)->gp_cv)) {
+ total_size += thing_size(generic_thing, tracking_hash);
+ }
+ }
}
}
break;
case SVt_PVFM:
total_size += sizeof(XPVFM);
if (go_yell) {
- carp("FM isn't complete");
+ carp("Devel::Size: Calculated sizes for FMs are incomplete");
}
break;
case SVt_PVIO:
total_size += sizeof(XPVIO);
- if (go_yell) {
- carp("IO isn't complete");
+ total_size += magic_size(thing, tracking_hash);
+ if (check_new(tracking_hash, ((XPVIO *) SvANY(thing))->xpv_pv)) {
+ total_size += ((XPVIO *) SvANY(thing))->xpv_cur;
}
+ /* Some embedded char pointers */
+ if (check_new(tracking_hash, ((XPVIO *) SvANY(thing))->xio_top_name)) {
+ total_size += strlen(((XPVIO *) SvANY(thing))->xio_top_name);
+ }
+ if (check_new(tracking_hash, ((XPVIO *) SvANY(thing))->xio_fmt_name)) {
+ total_size += strlen(((XPVIO *) SvANY(thing))->xio_fmt_name);
+ }
+ if (check_new(tracking_hash, ((XPVIO *) SvANY(thing))->xio_bottom_name)) {
+ total_size += strlen(((XPVIO *) SvANY(thing))->xio_bottom_name);
+ }
+ /* Throw the GVs on the list to be walked if they're not-null */
+ if (((XPVIO *) SvANY(thing))->xio_top_gv) {
+ total_size += thing_size((SV *)((XPVIO *) SvANY(thing))->xio_top_gv,
+ tracking_hash);
+ }
+ if (((XPVIO *) SvANY(thing))->xio_bottom_gv) {
+ total_size += thing_size((SV *)((XPVIO *) SvANY(thing))->xio_bottom_gv,
+ tracking_hash);
+ }
+ if (((XPVIO *) SvANY(thing))->xio_fmt_gv) {
+ total_size += thing_size((SV *)((XPVIO *) SvANY(thing))->xio_fmt_gv,
+ tracking_hash);
+ }
+
+ /* Only go trotting through the IO structures if they're really
+ trottable. If USE_PERLIO is defined we can do this. If
+ not... we can't, so we don't even try */
+#ifdef USE_PERLIO
+ /* Dig into xio_ifp and xio_ofp here */
+ croak("Devel::Size: Can't size up perlio layers yet");
+#endif
break;
default:
- croak("Unknown variable type");
+ croak("Devel::Size: Unknown variable type");
}
return total_size;
}
# Change 1..1 below to 1..last_test_to_print .
# (It may become useful if the test is moved to ./t subdirectory.)
-BEGIN { $| = 1; print "1..7\n"; }
+BEGIN { $| = 1; print "1..8\n"; }
END {print "not ok 1\n" unless $loaded;}
use Devel::Size qw(size total_size);
$loaded = 1;
# (correspondingly "not ok 13") depending on the success of chunk 13
# of the test code):
+use vars qw($foo @foo %foo);
+$foo = "12";
+@foo = (1,2,3);
+%foo = (a => 1, b => 2);
my $x = "A string";
my $y = "A longer string";
print "not ok 7\n";
}
+if (total_size(*foo)) {
+ print "ok 8\n";
+} else {
+ print "not ok 8\n";
+}