Welcome! Log In Create A New Profile

Advanced

Re: ngx_array.c allocation question

Valentin V. Bartenev
October 28, 2015 11:50AM
On Wednesday 28 October 2015 15:24:39 Lev Brouk wrote:
> Valentin and Joel,
> It would appear that a part of Joel's (and my own) concern could be alleviated if ngx_array_push called ngx_pfree on the old memory block after it grew it in https://github.com/nginx/nginx/blob/master/src/core/ngx_array.c#L76. I understand that (a) doing this would still leak all the "small" allocs, and (b) ngx_pfree call is potentially slow since it walks the chain of large allocations in the pool. But that could be an option, perhaps?

We usually don't have so big arrays in nginx that ngx_pfree can free.
So, calling it will be waste of CPU cycles most of the time.

> That aside, I too am wondering what memory management options (other than malloc) are available for data structures with long lifespans, or if there are any relevant development plans. It is certainly appealing to be able to use ngx_array_t and ngx_list_t in these "long-lived" use-cases.

AFAIK, no any dev plans at the moment. I'd suggest just to implement
some simple reuse mechanism for your data structures. That's what
nginx does for its chains and buffers that are reused during the
processing of request.

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 553 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 249 October 27, 2015 06:54PM

Re: ngx_array.c allocation question

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

Re: ngx_array.c allocation question

Lev Brouk 298 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 246 October 28, 2015 12:24PM



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

Online Users

Guests: 125
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