FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » php daemon
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: php daemon [message #179594 is a reply to message #179593] Sun, 11 November 2012 21:22 Go to previous messageGo to previous message
Christoph Becker is currently offline  Christoph Becker
Messages: 91
Registered: June 2012
Karma:
Member
Jerry Stuckle wrote:
> On 11/11/2012 3:05 PM, Christoph Becker wrote:
>> Jerry Stuckle wrote:
>>> All you can do is unset() variables. However, this does not release
>>> memory immediately. It would wait for the garbage collector to run.
>>
>> I'm very much surprised. I /assumed/ that PHP uses reference counting,
>> which would typically release the allocated memory as soon as the
>> reference count of a value is 0.
>>
>
> It does. But memory is not released until the garbage collector is run.
> See the PHP documentation.

Thanks for the pointer to the PHP documentation. According to
<http://php.net/manual/en/features.gc.refcounting-basics.php>:

| A PHP variable is stored in a container called a "zval". A zval
| container contains, besides the variable's type and value, two
| additional bits of information.
| [...]
| Variable containers get destroyed when the "refcount" reaches zero.
| [...]
| Again, when the "refcount" reaches zero, the variable container is
| removed from memory.

As this simple reference counting garbage collection isn't able to free
circular structures, a garbage collector [1] to do so was introduced in
PHP 5.3. Unfortunately the documentation isn't particularly clear here:

| If the refcount is decreased and hits zero, the zval can be freed.

But from the subsequent documentation I conclude, that the zval is
actually freed, when the refcount is decreased to zero.

[1] <http://www.php.net/manual/en/features.gc.collecting-cycles.php

--
Christoph M. Becker
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Benefits of the 3-Tier Architecture
Next Topic: Bad database design can cause unnecessary coding
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 08:17:26 GMT 2024

Total time taken to generate the page: 1.20046 seconds