Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: Memory usage of a "sub" in mod_perl

by shmem (Chancellor)
on May 23, 2008 at 19:53 UTC ( [id://688205]=note: print w/replies, xml ) Need Help??


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}

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://688205]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2024-04-25 23:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found