Re: Need help on memory allocation when developing an extension
| From: | Surf Chen | Date: | Sun, 18 Jan 2009 02:50:06 +0000 |
| Subject: | Re: Need help on memory allocation when developing an extension | ||
| References: | 1 | Groups: | php.pecl.dev |
| Request: | Send a blank email to pecl-dev+get-6062@lists.php.net to get a copy of this message | ||
On Sun, Jan 18, 2009 at 9:50 AM, Zhuguo Shi <blueflycn@gmail.com> wrote:
> Hello to every one,
> This is my first time to be here and I am doing some work with PHP
> extensions.
> I am new to this field and I have one question, please allow me to
> explain more specifically.
> Actually I am developing a PHP extension with C++, and it has to read
> data from a file every time it receives a request. So I wonder if I can put
> the initialization of that class into the extension's MINIT, including the
> reading data from file, so that it does not need to open and read file every
> time it performs its function.
> The reason why I want to do this is to reduce the IO time and increase
> its performance. If that is possible, can any one point out the key steps
> that I should do? If not, can some one give me some advices?
> Any help is of great appreciation, and thanks in advance~
>
of couse you can load that file in the MINIT and store the file
content in a global variable.Or you can read the file content in your
first function call and store in a global variable,then the next time
the function can use data from that global variable.
You even don't need to use a thread-safe global variable in this
case,so it is not different from programming in a normal c/c++
program.