Forum: NGINX How do i free memory when my master process ends?

1ba75714933d7ed0670abfb47a49d7ef?d=identicon&s=25 Adarsh Pugalia (Guest)
on 2014-06-02 12:46
(Received via mailing list)
I am allocating memory using malloc for some of my variables in my
module.
I know i can call an exit master process, but how do i access my
variables
in that function. I tried finding some examples, but didnt find any. Can
anyone guide me through this.
A8108a0961c6087c43cda32c8616dcba?d=identicon&s=25 Maxim Dounin (Guest)
on 2014-06-02 17:56
(Received via mailing list)
Hello!

On Mon, Jun 02, 2014 at 04:15:09PM +0530, Adarsh Pugalia wrote:

> I am allocating memory using malloc for some of my variables in my module.
> I know i can call an exit master process, but how do i access my variables
> in that function. I tried finding some examples, but didnt find any. Can
> anyone guide me through this.

Resource allocation and deallocations are usually done with pools
in nginx.  If you want to do some allocations which aren't from
pool (e.g., an opened file, or a memory allocated directly with
malloc() for some reason), it's usually good idea to add a pool
cleanup to do required deallocation when coresponding pool will be
destroyed.

Try looking into the code for ngx_pool_cleanup_add(), there are
lots of examples.

--
Maxim Dounin
http://nginx.org/
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.