in reply to Object::InsideOut leaks memory when using threads::shared

If you are at the point of grasping at straws, trying to forcefully destroy the object's refcount may work.

See Memory Leak? i'm clueless. for Object::Destroyer

and Memory leaks and circular references for Scalar::Util 'weaken'; Hope it helps.

Just as a hack, you might try to see if reusing your scalar $o, stops the memory gain.

my $o; while (1) { $o = new Test; }

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

Replies are listed 'Best First'.
Re^2: Object::InsideOut leaks memory when using threads::shared
by menth0l (Monk) on Oct 13, 2010 at 21:17 UTC
    Jerry D. Hedden has already answered to my bug report. He states that:
    (...)it's not an OIO bug. It's a problem with the perl interpreter and/or threads::shared.
    He managed though to fix this in new OIO version that he ut on CPAN (1.71):
    http://cpansearch.perl.org/src/JDHEDDEN/Object-InsideOut-3.71/Changes

    Thank you all for help and thanks to Jerry for quick reaction!
      it's not an OIO bug. It's a problem with the perl interpreter and/or threads::shared.

      Interesting fix/workaround:

      @@ -634,19 +634,23 @@ # Save deleted IDs for later reuse my $reuse = $GBL{'id'}{'reuse'}; + lock($reuse) if $GBL{'share'}{'ok'}; if ($id) { - lock($reuse) if $GBL{'share'}{'ok'}; if (! exists($$reuse{$tree})) { $$reuse{$tree} = make_shared([]); } my $r_tree = $$reuse{$tree}; if (! exists($$r_tree[$thread_id])) { - $$r_tree[$thread_id] = make_shared({}); - } elsif (exists($$r_tree[$thread_id]{$id})) { - warn("ERROR: Duplicate reclaimed object ID ($id) in class + tree for $tree in thread $thread_id\n"); - return; + $$r_tree[$thread_id] = make_shared([]); + } else { + foreach (@{$$r_tree[$thread_id]}) { + if ($_ == $id) { + warn("ERROR: Duplicate reclaimed object ID ($id) +in class tree for $tree in thread $thread_id\n"); + return; + } + } } - $$r_tree[$thread_id]{$id} = $id; + push(@{$$r_tree[$thread_id]}, $id); return; } @@ -654,9 +658,9 @@ if (exists($$reuse{$tree}) && exists($$reuse{$tree}[$thread_id])) { - keys(%{$$reuse{$tree}[$thread_id]}); - if ((my $id) = each(%{$$reuse{$tree}[$thread_id]})) { - return (delete($$reuse{$tree}[$thread_id]{$id})); + my $id = pop(@{$$reuse{$tree}[$thread_id]}); + if (defined($id)) { + return $id; } }

      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.