Devel-TrackObjects
view release on metacpan or search on metacpan
side effects
0.4 2010/11/01
- new options -timestamp,-size,-sizediff to get timestamps and
information about sizes and size changes in objects using
Devel::Size. Thanks to DetlefPilzecker[AT]web[DOT]de for
ideas and initial patch
0.3
- new function track_object, which can be used to track objects
manually for cases where not all objects of a class should be
tracked or if the object were created outside of perl
- verify in Makefile.PL, that the weaken from Scalar::Util is
usable (was not supported in old perl versions)
0.2
- bugfix for not compiled regex (given from cmdline)
- better documentation
0.1
- initial release
Makefile.PL view on Meta::CPAN
use ExtUtils::MakeMaker;
# make sure that weaken works
if ( eval { require Scalar::Util } ) {
eval { my $x; Scalar::Util::weaken(\$x ) };
if ($@) {
warn "Scalar::Util::weaken is not available for this perl: $@";
exit(0)
}
}
WriteMakefile(
NAME => 'Devel::TrackObjects',
VERSION_FROM => 'lib/Devel/TrackObjects.pm',
PREREQ_PM => {
'Scalar::Util' => 1.00,
},
lib/Devel/TrackObjects.pm view on Meta::CPAN
package Devel::TrackObjects;
use strict;
use warnings;
use Scalar::Util 'weaken';
use overload;
our $VERSION = '0.601';
my @weak_objects; # List of weak objects incl file + line
my @conditions; # which objects to track, set by import
my $is_redefined; # flag if already redefined
my $old_bless; # bless sub before redefining
my $debug; # enable internal debugging
lib/Devel/TrackObjects.pm view on Meta::CPAN
if $debug;
#0: referenz
#1: file name
#2: line in file
#3: info message
#4: initial size
#5: initial total_size
#6: last size
#7: last total_size
push @weak_objects, [ $ref,$fname,$line,$info ];
weaken( $weak_objects[-1][0] );
}
############################################################################
# eliminate destroyed objects, eg where the weak ref is undef
############################################################################
sub _remove_destroyed {
@weak_objects = grep { defined( $_->[0] ) } @weak_objects;
}
( run in 0.923 second using v1.01-cache-2.11-cpan-65fba6d93b7 )