Reply to Re: Garbage collection

Your name:

Reply:


Posted by gosha bine on 04/27/07 08:06

On 27.04.2007 02:10 amygdala 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?

In a scripting language you usually don't need to manage memory
explicitly, however there are some caveats in php MM you should know
about, for example, circular references.

>
> 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.

Yes, they do, therefore your best option is to keep code structured, use
functions and avoid global variables.

>
> 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?

This should be this way, however there may be bugs in php core or
extensions that prevent memory from being freed.

>
> Thank you for any tips / advice on the matter.
>
>


--
gosha bine

extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация