in reply to Re^2: Memory usage of a "sub" in mod_perl
in thread Memory usage of a "sub" in mod_perl

and then undef $page->{html}. Shouldn't "undef" be enough?

That depends upon what that hash entry actually is. If it is a reference (or something containing a reference) to data which is held elsewhere, you just clear that slot from the reference, but not the referenced data.

Consider:

perl -le '$foo = "bar"; $h->{foo} = \$foo; undef $h->{foo}; print "foo + :$foo:"' foo :bar:

which is different to

perl -le '$foo = "bar"; $h->{foo} = \$foo; undef ${$h->{foo}}; print " +foo :$foo:"' foo ::

where the referenced data is cleared.

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

Replies are listed 'Best First'.
Re^4: Memory usage of a "sub" in mod_perl
by diego_de_lima (Beadle) on May 23, 2008 at 20:09 UTC
    In my case, $page->{html} is a simple string, like:
    $page->{html} = '...ALL HTML HERE 2 MB OF PLAIN TEXT...';
    
    So, isnīt undef $page->{html} enought?

    Diego de Lima
      Yes, that should do - but only if there's no reference to that string elsewhere.

      --shmem

      _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                    /\_¯/(q    /
      ----------------------------  \__(m.====·.(_("always off the crowd"))."·
      ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}