Re: Small question about performance

From: Date: Thu, 15 Mar 2012 18:58:25 +0000
Subject: Re: Small question about performance
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message


Am 15.03.2012 18:41, schrieb Paul Dragoonis:
>>> I don't really know when PHP frees temporary variables, but my guess
>>> was that they are freed when the scope is left.
>>
>> Each variable has a refcount, then that hits 0 it can be freed up.
> 
> To add to that. A zval will have a refcount, so if you do $a =
> someFunc(); then $a will have a refcount.
> 
> If you do something like $a = someFunc(anotherFunc(moreFunc())), the
> return values of anotherFunc() and moreFunc() will be temp stored, but
> they will _not_ have a refcount because they never got assigned into a
> zval like $a.

to make sure i understand this really

function myfunc()
{
 $b = internal_function_with_hughe_return_value();
 return false;
}

$b is freed after the function has finished
if not i should write a lot of unset() what
is not possible if you have return $b






Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc

Thread (12 messages)

« previous php.internals (#58969) next »