Welcome! Log In Create A New Profile

Advanced

Re: memory leak at ngx_pool_cleanup_add ?

Maxim Dounin
October 12, 2010 01:18PM
Hello!

On Tue, Oct 12, 2010 at 08:59:13PM +0400, Franchoze Eric wrote:

>
>
> 12.10.10, 01:45, "Franchoze Eric" <franchoze@yandex.ru>:
>
> > Is free() needed here?
> >
> > ngx_pool_cleanup_t *
> > ngx_pool_cleanup_add(ngx_pool_t *p, size_t size)
> > {
> > ngx_pool_cleanup_t *c;
> >
> > c = ngx_palloc(p, sizeof(ngx_pool_cleanup_t));
> > if (c == NULL) {
> > return NULL;
> > }
> >
> > if (size) {
> > c->data = ngx_palloc(p, size);
> > !!! do we need nginx_free(p); here?!!!!
> >
> > if (c->data == NULL) {
> > return NULL;
> > }
> >
>
> Opps, I mean nginx_free(c) of cource. It is allocated in lines
> above and if c->data is not allotated it just returns from
> function without freeing c.

The answer is still the same: no.

It's pool allocator, and all memory is freed on pool destruction
(which is expected to follow allocation error shortly).

Additionally, in nginx's pool allocator only large memory blocks
may be freed individually (though it's still not required),
freeing small allocations aren't supported at all.

Maxim Dounin

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

memory leak at ngx_pool_cleanup_add ?

Franchoze Eric 2408 October 11, 2010 05:46PM

Re: memory leak at ngx_pool_cleanup_add ?

Maxim Dounin 874 October 11, 2010 06:24PM

Re: memory leak at ngx_pool_cleanup_add ?

Franchoze Eric 742 October 12, 2010 01:00PM

Re: memory leak at ngx_pool_cleanup_add ?

Maxim Dounin 836 October 12, 2010 01:18PM

ngx_rewrite_set()

Eugaia 990 October 12, 2010 08:16PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 83
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready