Welcome! Log In Create A New Profile

Advanced

Re: ngx_array.c allocation question

Valentin V. Bartenev
October 27, 2015 05:44PM
On Tuesday 27 October 2015 20:52:43 Joel Cunningham wrote:
> Hi,
>
> I'm fairly new to the NGINX sources and have been studying ngx_array.c (from
1.9.5), particularly how the array grows when full.
>
> I'm having some confusion about how pool memory isn't leaked when the new
array size can not fit within the current pool allocation and we call
ngx_palloc(). The new allocation is assigned to the local variable new, which
is eventually assigned to a->elts, but the old memory that was claimed out of
the previous pool allocation (and tracked by a->elts) isn't released/marked as
no longer used in the pool. I would have expected some manipulation of p-
>d.last, similarly to how ngx_array_destroy() releases the memory from the
pool allocation. Is there something I'm not understanding about the way array
uses the memory pool?
>
> It seems like over time an array that continues to grow (past the current
pool allocation) would leave memory claimed within the pool allocation that
it's no longer using or tracking
>

It's ok, since pools usually have relatively short lives.

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 550 October 27, 2015 04:54PM

Re: ngx_array.c allocation question

Valentin V. Bartenev 277 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: 177
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