summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGianni Ceccarelli <gianni.ceccarelli@net-a-porter.com>2011-12-22 16:54:52 +0000
committerGianni Ceccarelli <gianni.ceccarelli@net-a-porter.com>2011-12-22 16:54:52 +0000
commit232ec507ed438fce63991f6ce8169365f430f062 (patch)
tree0ff3a084bce4402c7e52b4b67af406191df4c232
parentBuild results of 8bb2d9b (on master) (diff)
parentremove MooseX::Types as far as sensible (diff)
downloaddata-multivalued-232ec507ed438fce63991f6ce8169365f430f062.tar.gz
data-multivalued-232ec507ed438fce63991f6ce8169365f430f062.tar.bz2
data-multivalued-232ec507ed438fce63991f6ce8169365f430f062.zip
Build results of e9892ef (on master)
-rw-r--r--Changes2
-rw-r--r--MANIFEST1
-rw-r--r--author_t/leaks.t75
-rw-r--r--lib/Data/MultiValued/AttributeTrait.pm5
-rw-r--r--lib/Data/MultiValued/Ranges.pm15
-rw-r--r--lib/Data/MultiValued/Tags.pm9
-rw-r--r--lib/Data/MultiValued/TagsAndRanges.pm19
7 files changed, 99 insertions, 27 deletions
diff --git a/Changes b/Changes
index 0f66514..7f8beba 100644
--- a/Changes
+++ b/Changes
@@ -1,6 +1,6 @@
Revision history for Data::MultiValued
-0.0.1_5 2011-12-22 15:11:28 Europe/London
+0.0.1_5 2011-12-22 16:54:47 Europe/London
0.0.1_4 2011-12-20 10:02:30 Europe/London
- don't use Throwable::Error, we don't need stack traces, and they
diff --git a/MANIFEST b/MANIFEST
index 36cc917..b75414c 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -3,6 +3,7 @@ MANIFEST
META.json
META.yml
Makefile.PL
+author_t/leaks.t
dist.ini
lib/Data/MultiValued.pm
lib/Data/MultiValued/AttributeAccessors.pm
diff --git a/author_t/leaks.t b/author_t/leaks.t
new file mode 100644
index 0000000..f3c811b
--- /dev/null
+++ b/author_t/leaks.t
@@ -0,0 +1,75 @@
+#!perl
+use strict;
+use warnings;
+package Foo;{
+use Moose;
+use Data::MultiValued::AttributeTrait::Ranges;
+
+with 'Data::MultiValued::UglySerializationHelperRole';
+
+has rr => (
+ is => 'rw',
+ isa => 'Str',
+ traits => ['MultiValued::Ranges'],
+ predicate => 'has_rr',
+ clearer => 'clear_rr',
+);
+
+}
+package main;
+use Test::Most 'die';
+use Data::Printer;
+use JSON::XS;
+BEGIN { $ENV{DEBUG_MEM}=1 };
+use Dash::Leak;
+
+my $ropts={from=>10,to=>20};
+
+my $json = JSON::XS->new->utf8;
+my $obj = Foo->new(rr=>'foo');
+$obj->rr_multi($ropts,777);
+
+subtest 'serialisation memory leak' => sub {
+ $obj=Foo->new_in_place($json->decode($json->encode($obj->as_hash)));
+ leaksz 'start memory leak';
+ for my $iter (0..2000) {
+ $obj=Foo->new_in_place($json->decode($json->encode($obj->as_hash)));
+ }
+ leaksz 'stop memory leak';
+ ok(1,'done');
+};
+
+subtest 'accessor memory leak' => sub {
+ leaksz 'start memory leak';
+ for my $iter (0..1000) {
+ $obj->rr_multi({at=>35});
+ }
+ leaksz 'stop memory leak non-exist';
+ leaksz '...';
+ for my $iter (0..1000) {
+ $obj->rr_multi({at=>15});
+ }
+ leaksz 'stop memory leak exist';
+
+ ok(1,'done');
+};
+
+subtest 'inner memory leak' => sub {
+ my $cont = $obj->{rr__MULTIVALUED_STORAGE__}
+ {_storage};
+
+ leaksz 'start memory leak';
+ for my $iter (0..1000) {
+ eval { $cont->get({at=>35}) }
+ }
+ leaksz 'stop memory leak non-exist';
+ leaksz '...';
+ for my $iter (0..1000) {
+ $cont->get({at=>15});
+ }
+ leaksz 'stop memory leak exist';
+
+ ok(1,'done');
+};
+
+done_testing();
diff --git a/lib/Data/MultiValued/AttributeTrait.pm b/lib/Data/MultiValued/AttributeTrait.pm
index 3aeb3c0..24c6e03 100644
--- a/lib/Data/MultiValued/AttributeTrait.pm
+++ b/lib/Data/MultiValued/AttributeTrait.pm
@@ -8,7 +8,6 @@ package Data::MultiValued::AttributeTrait;
use Moose::Role;
use namespace::autoclean;
use Data::MultiValued::AttributeAccessors;
-use MooseX::Types::Moose qw(Str);
use Try::Tiny;
use namespace::autoclean;
@@ -17,7 +16,7 @@ use namespace::autoclean;
has 'full_storage_slot' => (
is => 'ro',
- isa => Str,
+ isa => 'Str',
lazy_build => 1,
);
sub _build_full_storage_slot { shift->name . '__MULTIVALUED_STORAGE__' }
@@ -28,7 +27,7 @@ my @accs_to_multiply=qw(accessor reader writer predicate clearer);
for my $acc (@accs_to_multiply) {
has "multi_$acc" => (
is => 'ro',
- isa => Str,
+ isa => 'Str',
predicate => "has_multi_$acc",
);
}
diff --git a/lib/Data/MultiValued/Ranges.pm b/lib/Data/MultiValued/Ranges.pm
index 186a7de..9beb1a8 100644
--- a/lib/Data/MultiValued/Ranges.pm
+++ b/lib/Data/MultiValued/Ranges.pm
@@ -7,9 +7,8 @@ package Data::MultiValued::Ranges;
}
use Moose;
use namespace::autoclean;
-use MooseX::Params::Validate;
use Moose::Util::TypeConstraints;
-use MooseX::Types::Moose qw(Num Str Undef Any);
+use MooseX::Params::Validate;
use Data::MultiValued::Exceptions;
use Data::MultiValued::RangeContainer;
@@ -31,9 +30,9 @@ sub _build__storage {
sub set {
my ($self,%args) = validated_hash(
\@_,
- from => { isa => Num|Undef, optional => 1, },
- to => { isa => Num|Undef, optional => 1, },
- value => { isa => Any, },
+ from => { isa => 'Num|Undef', optional => 1, },
+ to => { isa => 'Num|Undef', optional => 1, },
+ value => { isa => 'Any', },
);
$self->_storage->get_or_create(\%args)
@@ -44,7 +43,7 @@ sub set {
sub get {
my ($self,%args) = validated_hash(
\@_,
- at => { isa => Num|Undef, optional => 1, },
+ at => { isa => 'Num|Undef', optional => 1, },
);
$self->_storage->get(\%args)
@@ -55,8 +54,8 @@ sub get {
sub clear {
my ($self,%args) = validated_hash(
\@_,
- from => { isa => Num|Undef, optional => 1, },
- to => { isa => Num|Undef, optional => 1, },
+ from => { isa => 'Num|Undef', optional => 1, },
+ to => { isa => 'Num|Undef', optional => 1, },
);
$self->_storage->clear(\%args);
diff --git a/lib/Data/MultiValued/Tags.pm b/lib/Data/MultiValued/Tags.pm
index 5806a14..6d213d4 100644
--- a/lib/Data/MultiValued/Tags.pm
+++ b/lib/Data/MultiValued/Tags.pm
@@ -9,7 +9,6 @@ use Moose;
use namespace::autoclean;
use MooseX::Params::Validate;
use Moose::Util::TypeConstraints;
-use MooseX::Types::Moose qw(Num Str Undef Any);
use Data::MultiValued::Exceptions;
use Data::MultiValued::TagContainer;
@@ -31,8 +30,8 @@ sub _build__storage {
sub set {
my ($self,%args) = validated_hash(
\@_,
- tag => { isa => Str, optional => 1, },
- value => { isa => Any, },
+ tag => { isa => 'Str', optional => 1, },
+ value => { isa => 'Any', },
);
$self->_storage->get_or_create(\%args)
@@ -43,7 +42,7 @@ sub set {
sub get {
my ($self,%args) = validated_hash(
\@_,
- tag => { isa => Str, optional => 1, },
+ tag => { isa => 'Str', optional => 1, },
);
$self->_storage->get(\%args)
@@ -54,7 +53,7 @@ sub get {
sub clear {
my ($self,%args) = validated_hash(
\@_,
- tag => { isa => Str, optional => 1, },
+ tag => { isa => 'Str', optional => 1, },
);
$self->_storage->clear(\%args);
diff --git a/lib/Data/MultiValued/TagsAndRanges.pm b/lib/Data/MultiValued/TagsAndRanges.pm
index d8e8d83..e75f0f5 100644
--- a/lib/Data/MultiValued/TagsAndRanges.pm
+++ b/lib/Data/MultiValued/TagsAndRanges.pm
@@ -9,7 +9,6 @@ use Moose;
use namespace::autoclean;
use MooseX::Params::Validate;
use Moose::Util::TypeConstraints;
-use MooseX::Types::Moose qw(Num Str Undef Any);
use Data::MultiValued::Exceptions;
use Data::MultiValued::TagContainerForRanges;
@@ -31,10 +30,10 @@ sub _build__storage {
sub set {
my ($self,%args) = validated_hash(
\@_,
- from => { isa => Num|Undef, optional => 1, },
- to => { isa => Num|Undef, optional => 1, },
- tag => { isa => Str, optional => 1, },
- value => { isa => Any, },
+ from => { isa => 'Num|Undef', optional => 1, },
+ to => { isa => 'Num|Undef', optional => 1, },
+ tag => { isa => 'Str', optional => 1, },
+ value => { isa => 'Any', },
);
$self->_storage->get_or_create(\%args)
@@ -46,8 +45,8 @@ sub set {
sub get {
my ($self,%args) = validated_hash(
\@_,
- at => { isa => Num|Undef, optional => 1, },
- tag => { isa => Str, optional => 1, },
+ at => { isa => 'Num|Undef', optional => 1, },
+ tag => { isa => 'Str', optional => 1, },
);
$self->_storage->get(\%args)
@@ -59,9 +58,9 @@ sub get {
sub clear {
my ($self,%args) = validated_hash(
\@_,
- from => { isa => Num|Undef, optional => 1, },
- to => { isa => Num|Undef, optional => 1, },
- tag => { isa => Str, optional => 1, },
+ from => { isa => 'Num|Undef', optional => 1, },
+ to => { isa => 'Num|Undef', optional => 1, },
+ tag => { isa => 'Str', optional => 1, },
);
if (exists $args{from} || exists $args{to}) {