releasing memory.

Dk Jack dnj0496 at
Thu May 18 22:06:32 UTC 2017

My module has c++ code which instantiates a class. I am driving most of my
from one ptr which I am saving in the context.

I tried changing my code to use pool cleanup, it behaving worse than
Of the four requests I send, the cleanup handler is only getting called for

I did a little more digging into the request->cleanup issue. It looks like,
for the case
where I thought my cleanup handler wasn't getting called, it was actually
called. In my handler I was trying to retrieve my module context
I could not retrieve the module context in the failure case. I allocated my
from r->connection->pool. I suspect, in the failure case the contexts are
freed before the clean up callbacks are complete.

On Thu, May 18, 2017 at 10:57 AM, Maxim Dounin <mdounin at> wrote:

> Hello!
> On Thu, May 18, 2017 at 10:23:18AM -0700, Dk Jack wrote:
> > I just want to release memory l've allocated. One more question,
> > is the context memory automatically removed or is the module
> > responsible for freeing it.
> Anything you allocate from request pool (r->pool) using
> ngx_p*alloc() functions is automatically freeded when the request
> pool is destroyed.  If you allocate memory directly from OS, you
> are responsible to free it yourself (though this shouldn't happen
> except in very special cases).
> --
> Maxim Dounin
> _______________________________________________
> nginx-devel mailing list
> nginx-devel at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nginx-devel mailing list