|
Posted by ZeldorBlat on 04/27/07 00:27
On Apr 26, 8:10 pm, "amygdala" <nore...@noreply.com> wrote:
> Hi,
>
> I've read a few threads in this group recently, discussing garbage
> collecting and unsetting variables and the likes. Concerning memory usage in
> PHP: what is good practice, i.e. what should I be worried about, or what
> kind of garbage collecting of my own should I consider?
>
> Would it be good practice for instance to unset or set variables to NULL
> immediately when I don't need them anymore. Also: do variables dissapear
> from memory when out of scope? I would hope so.
>
> Finally my gutfeeling tells me, that when a script stops, the memory that
> was taken up by the script would clear instantly, but that doesn't always
> seem the case considering what some people here have mentioned about it.
> What's the real deal?
>
> Thank you for any tips / advice on the matter.
This is what my boss likes to call "premature optimization." In
practice, you don't need to worry about any of this. If you run into
a specific problem, deal with it then. Un-setting all your variables
or setting them all to null when you're done will just clutter your
code. And yes, the memory used by a script should be released
automatically when the script is finished.
[Back to original message]
|