Re: Re: How to create Persistent zval?
| From: | Stas Malyshev | Date: | Mon, 20 Jan 2014 08:00:40 +0000 |
| Subject: | Re: Re: How to create Persistent zval? | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-71304@lists.php.net to get a copy of this message | ||
Hi!
> And zend engine cleans up zvals at the end of request no matter the ref cnt
> is?
Yes and no. Zend Engine will clean up all emalloc-ed memory. It also
will clean up all symbol tables, objects, resources, etc. that are
stored in system tables. However, if you just create a zval structure
with persistent pemalloc, it would not be cleaned - but you could not
put this zval into any object, structure, etc., and passing it to engine
functions may be dangerous too. If you're knowing what you're doing, you
can pull it off (opcache sometimes does stuff like that IIRC) but you
need to be extremely careful so that the engine does not store your zval
and does not try to free it.
> so zval is not persistent, then is HashTable persistent?
>
> It's because I need to store a zval object which has several properties.
> Is there a way to do make the object persistent? Or do i need to serialize
> it just like apc?
Serializing it one way or another (doesn't have to be full serialize -
serialize is pretty complex since it has to account for all corner
cases, you can have something much simpler and use serialize handlers or
custom code) may be the simplest way. It is possible to also keep
objects in memory as is if you're very careful but it is not as simple
to do it right.
--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227