News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Paul Jones' Blog:
Memory Leaks With Objects in PHP 5
September 28, 2007 @ 08:46:00

Paul Jones presents a problem he was having in a new post to his blog - the issue was with memory leaks in objects in a PHP5 application he was working on.

One of the nice things about using a scripting language is that it automates garbage collection for you. You don't have to worry about releasing memory when you're done with your variables. [...] But there is at least one circumstance in which PHP will not free memory for you when you call unset(). Cf. http://bugs.php.net/bug.php?id=33595.

The problem is that, when trying to unset the parent object in a parent/child relationship, the memory space for the parent reference in the child isn't removed. The problem, left unchecked can cause a script to go over the memory limit pretty easily (especially with larger objects).

He suggests two solutions - one that the user can control (calling a destructor before unsetting the object) or a PHP internals method that involves fixing issues with the reference counts created with the objects.

0 comments voice your opinion now!
memory leak object php5 reference parent child release memory leak object php5 reference parent child release


blog comments powered by Disqus

Similar Posts

Gentoo Blog: PHP's Simplicity Can Confuse Folks Looking For Complexity

Ilia Alshanetsky's Blog: PHP 5.2.0 RC4 Released!

Stefan Mischook's Blog: OOP in PHP: New PHP Article in Web Designer Magazine (Nov 2006)

Mike Naberezny\'s Blog: Fluent Interfaces in PHP

Jim Plush's Blog: MyBic - New Release and SourceForge Ranking


Community Events

Don't see your event here?
Let us know!


laravel5 api library language opinion framework example security laravel extension list version release introduction interview podcast php7 voicesoftheelephpant series community

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework