New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory leak in tied Hash #8979
Comments
From holger.seelig@yahoo.deHello, Creating copies of blessed objects in a tied hash during overloaded The code below describes the problem. package Tie::Objects; use Tie::Hash; sub TIEHASH { bless \$_[1], $_[0] } sub FETCH { ${ $_[0] }->{ $_[1] }->getClone } sub STORE { ${ $_[0] }->{ $_[1] }->setValue( $_[2] ) } package Vec2; use overload '""' => sub { join " ", @{ $_[0] } }; sub new { bless $_[1] || [ 0, 0 ], 'Vec2' } sub DESTROY { print "DESTROY Vec2"; 0; } package Object; use overload '""' => sub { $_[0]->{value} }; sub new { bless { value => new Vec2 $_[1] }, 'Object' } sub getClone { $_[0]->new( [ @{ $_[0]->{value} } ] ) } sub getValue { $_[0]->{value} } package main; my $objects = {}; $objects->{v1} = new Object( [ 1, 1 ] ); print "# Block 1 ################"; print "# END ###############"; 1; Output of the code above: # Block 1 ################ As you can see the the tree copies of Vec2 created in the tied hash are Yours sincerely holger@laptop$ uname -a holger@laptop$ perl -v This is perl, v5.8.8 built for i486-linux-gnu-thread-multi Copyright 1987-2006, Larry Wall Perl may be copied only under the terms of either the Artistic License Complete documentation for Perl, including FAQ lists, should be found on holger@laptop$ perl -V Characteristics of this binary (from libperl): |
From l2ot9pa02@sneakemail.comHolger Seelig schrieb:
This isn't a confirmation that it's actually a problem and not intended # Block 1 ################ Steffen |
The RT System itself - Status changed from 'new' to 'open' |
From holger.seelig@yahoo.deI tested the script under ActivePerl-5.10. The scripts output is still # Block 1 ################ perl version from terminal: This is perl, v5.10.0 built for x86_64-linux-thread-multi Copyright 1987-2007, Larry Wall Binary build 1003 [285500] provided by ActiveState Perl may be copied only under the terms of either the Artistic License Complete documentation for Perl, including FAQ lists, should be found on |
Migrated from rt.perl.org#44253 (status was 'open')
Searchable as RT44253$
The text was updated successfully, but these errors were encountered: