Re: Re: PHP memory usage

From: Date: Fri, 03 Jan 2003 08:37:38 +0000
Subject: Re: Re: PHP memory usage
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-130072@lists.php.net to get a copy of this message
At 01:25 AM 1/3/03 -0200, Fernando Serboncini wrote:
function a(myclass c) {
    return c;
} would create another copy of "c" in memory. Things get a bit larger when you go with linked-list like structures in classes, where you have to take really good care to don't duplicate data. If you're not taking care, then maybe 5MB is normal.
Not really. PHP has its own method of handling variables which does not make a copy of data unless it has to. See: http://www.zend.com/zend/art/ref-count.php This may be the most important paragraph in the article: Note that PHP 4 is not like C: passing variables by reference is not necessarily faster than passing them by value. Indeed, in PHP 4 it is usually better to pass a variable by value, except if the function changes the passed value or if a reference is being passed. Rick

« previous php.general (#130072) next »