Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Freeing perl memory?

by Anonymous Monk
on Jan 14, 2000 at 08:31 UTC ( #2101=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

How can you coerce perl into actually freeing memory that it has allocated? Perl garbage collects memory from unused values. However, this memory is not actually released from the perspective of the OS. A section from the book "Advanced Perl Programming" states
"For efficiency, Perl doesn't actually delete it; it just sends it to its own free pool and reuses it when you need a new value. It is logically deleted, nevertheless."

How can you force perl to release its memory pool?

Replies are listed 'Best First'.
Re: Freeing perl memory?
by halxd2 (Monk) on Jan 28, 2000 at 20:45 UTC
    I had hoped for a better answer to this question. I had been counting on perl's garbage collector to free memory. Now I see that I must be more conservitave with my memory use. A varible that dies with it's subrutine doesn't free that memory. I use little test varibles like $junk to test output before commiting changes. I can see now that the testing varible needs to be global. It really changes the way I'll be using memory in perl. fork()'ing might be a quicky solution, but we need to look for ways to trace memory use. Memory leaks in long running programs would cause major problems.
RE: Freeing perl memory?
by Anonymous Monk on Jan 18, 2000 at 00:13 UTC
    Most operating systems don't really let processes hand back memory once it has been allocated. Apple Macs can, I hear, but unixes and windows don't let you.
      Thats for perl only. All OSes allow programs to free memory back to the system.
Re: Freeing perl memory?
by Anonymous Monk on Jan 20, 2000 at 22:30 UTC
    IIRC, you can't force perl to return memory. However you can fork() and kill the parent process which will free the memory. It's pretty expensive to do, but might be worthwhile if it's a long running script. Dave

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://2101]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2019-12-10 02:33 GMT
Find Nodes?
    Voting Booth?

    No recent polls found