Welcome! Log In Create A New Profile

Advanced

Re: ngx_array.c allocation question

Valentin V. Bartenev
October 28, 2015 09:44AM
On Tuesday 27 October 2015 22:51:53 Joel Cunningham wrote:
> Request pools seem short lived, but the cycle pool sticks around for a long time.
>
> I'm working on a custom module that has state which should persist the entire uptime of NGINX. I was going to use an array allocated out of the cycle pool, but now I'm not sure that's a good idea. My array could grow and potentially leak memory in the cycle pool. Maybe the cycle pool allocation is big enough we never actually exceed the allocation and each array grow will continue to use the current allocation? Default size is 16KB. My module could have its own pool, but the same leak could happen within that.
>
> Would you say this was an intentional design decision or a bug? Doesn't look like it would be hard to fix assuming my understanding of ngx_array.c is correct.
>
[..]

It's an intentional design decision. Moreover, there's no easy way
to return memory to pool. Even ngx_array_destroy() returns memory
only in very specific case, when the destruction is happened right
after the allocation, so it works only for some temporary arrays.

wbr, Valentin V. Bartenev

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

ngx_array.c allocation question

Joel Cunningham 551 October 27, 2015 04:54PM

Re: ngx_array.c allocation question

Valentin V. Bartenev 278 October 27, 2015 05:44PM

Re: ngx_array.c allocation question

Joel Cunningham 248 October 27, 2015 06:54PM

Re: ngx_array.c allocation question

Valentin V. Bartenev 250 October 28, 2015 09:44AM

Re: ngx_array.c allocation question

Lev Brouk 297 October 28, 2015 11:26AM

Re: ngx_array.c allocation question

Valentin V. Bartenev 252 October 28, 2015 11:50AM

Re: ngx_array.c allocation question

Joel Cunningham 244 October 28, 2015 12:24PM



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

Online Users

Guests: 118
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready