Welcome! Log In Create A New Profile

Advanced

Re: when ngx_array_t allocate a new array, why not ngx_pfree pre a->elts?

Vladimir Shebordaev
May 22, 2012 11:54AM
Hi!

2012/5/22 l.jay Yuan <pass86@gmail.com>:
> when ngx_array_t allocate a new array, why not ngx_pfree pre a->elts?
>

Well, it seems to be a generic design decision. If you allocate a
dynamic object from the pool, you do it for speed, so, it is the most
likely relevant to the current request processing and supposed to be
destroyed right after that. It is done all at once when you
explicitely destroy the pool, either the objects are allocated from
one of the server pools that only persist during the current request
processing. Since there is no need in partial memory reclamaition, it
is faster to just allocate the memory anew.

> btw: ngx_pfree only free large memory, so I can not use ngx_pool_t everywhere...
>

If you do need the objects that would persist through different
request processing and the server reloading, you might want to use
ngx_slab_pool_t on some shared memory region. As far as I can recall
at the moment, nginx slab allocator provides necessary reclamaition
facilities.

--
Regards,
Vladimir

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

when ngx_array_t allocate a new array, why not ngx_pfree pre a->elts?

l.jay Yuan 1476 May 22, 2012 07:40AM

Re: when ngx_array_t allocate a new array, why not ngx_pfree pre a->elts?

Vladimir Shebordaev 493 May 22, 2012 11:54AM

Re: when ngx_array_t allocate a new array, why not ngx_pfree pre a->elts?

l.jay Yuan 633 May 22, 2012 12:58PM

Re: when ngx_array_t allocate a new array, why not ngx_pfree pre a->elts?

l.jay Yuan 669 May 22, 2012 12:58PM



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

Online Users

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