Re: persistent zval
| From: | Andrea Faulds | Date: | Tue, 09 Dec 2014 19:51:46 +0000 |
| Subject: | Re: persistent zval | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-79515@lists.php.net to get a copy of this message | ||
> On 9 Dec 2014, at 19:45, Marc Bennewitz <dev@mabe.berlin> wrote:
>
>
> Am 09.12.2014 um 20:03 schrieb Sara Golemon:
>> On Tue, Dec 9, 2014 at 10:58 AM, Marc Bennewitz <dev@mabe.berlin> wrote:
>>> Is it possible to make a zval persistent?
>>>
>> Nope.
>>
> Why?
>
> There is a reference counter, which should be increased on put a value into persistence and on
> removing a value from persistence decrease it.
> So the GC could handle unreferenced zvals.
>
> Example:
> persist_set($key, $value);
> persist_get($key);
> persist_has($key);
> persist_list(); // list of persistent values
No, no the GC couldn’t. All zval data is stored in non-persistent memory allocated with emalloc().
The allocator destroys all of that at the end of the request/script execution. So you’d now have a
dangling pointer. Kabewm!
--
Andrea Faulds
http://ajf.me/