Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Freeing up memory

by Gorby (Monk)
on Mar 17, 2003 at 09:21 UTC ( #243608=perlquestion: print w/replies, xml ) Need Help??

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

Hello wise monks. How can I make sure that my script frees up the memory it uses up at run time when it exits? My server administrator keeps telling me that the free RAM on my server depletes slowly everyday, and he claims that my script is "holding on" to some RAM everytime it runs and keeps it occupied even after it exits. Is this at all a reasonable contention by my server administrator? If a script exits properly, doesn't it automatically free up the RAM it used at run time? I'm confused. Thanks in advance for your wisdom.

Replies are listed 'Best First'.
Re: Freeing up memory
by robartes (Priest) on Mar 17, 2003 at 09:31 UTC
    If your script exits properly every time, it should release all of the memory it has used during runtime. If it is 'holding on' to the RAM as you say, there are a few possibilities:
    • Your administrator is mistaken or there is some confusion between you and him
    • Your script is not, in fact, exiting (perhaps you are creating zombie processes)
    • There is a bug in the Operating System you are using (very unlikely)
    I would put my money on either of the first two points. Check whether your script is still running when you think it should not be, otherwise, your administrator is probably wrong.

    For some background information on memory managment in general, see this recent thread.


      It might be that the script is actually a mod_perl handler - and in this case it can happen that the memory is not released.
Re: Freeing up memory
by BrowserUk (Pope) on Mar 17, 2003 at 10:07 UTC

    A little more information would go a very long way to allowing us to do something other than guess.

    Which version of Perl? Which OS? What does the script do? Does it use threads? Spawn processes? Use external resources like DB's, IPC etc?

    Examine what is said, not who speaks.
    1) When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong.
    2) The only way of discovering the limits of the possible is to venture a little way past them into the impossible
    3) Any sufficiently advanced technology is indistinguishable from magic.
    Arthur C. Clarke.
Re: Freeing up memory
by traveler (Parson) on Mar 17, 2003 at 15:13 UTC
    You might also check some of the replies to the last time you asked this question: some code would still help as would info on your OS and web server software.


Re: Freeing up memory
by fokat (Deacon) on Mar 17, 2003 at 12:36 UTC

    Without further information, it is quite hard to give you precise answers. I tend to agree with robartes, specially with his first two explanations. You might find this node as well as the whole discussion to which it belongs, instructive in your current situation.

    Best regards

    -lem, but some call me fokat

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2019-12-11 08:28 GMT
Find Nodes?
    Voting Booth?

    No recent polls found