Re: Global variables lifetime
| From: | Alexey Zakhlestin | Date: | Thu, 04 Dec 2008 19:50:45 +0000 |
| Subject: | Re: Global variables lifetime | ||
| References: | 1 | Groups: | php.pecl.dev php.pecl.dev |
| Request: | Send a blank email to pecl-dev+get-5960@lists.php.net to get a copy of this message | ||
On Thu, Dec 4, 2008 at 10:22 PM, Themis Vassiliadis
<tvassiliadis@gmail.com> wrote:
> I'm developing a new extension and it will be necessary to set and access
> data from variables sharing them between each request. Normanly this
> variable just need be declared as global or static.
>
> In extensions I read that we can do something like that using
> ZEND_INIT_MODULE_GLOBALS() and ZEND_DECLARE_MODULE_GLOBALS() macros.
>
> How is the variable lifetime ? Precisely the variable should be used at
> webserver startup and still using it until shutdown without lose any data
> and this should be done in any webserver and plataform (Apache, IIS etc) ???
>
> Explanations will be very appreciated.
As long, as you use malloc() to allocate memory, it will not be
gathered by garbage collector, so it's lifetime is defined by you.
--
Alexey Zakhlestin
http://www.milkfarmsoft.com/