memory pool allocation
Ruslan Ermilov
ru at nginx.com
Thu Apr 10 07:25:48 UTC 2014
On Wed, Apr 09, 2014 at 08:31:29AM -0400, nginxsantos wrote:
> Suppose, I am allocating a pool of greater than 4k(page size). Say for
> example I am calling the function ngx_create_pool with 8096.
> But, this function will set the max as 4095 even if it has allocated 8K. Not
> sure, why is it being done like this.
>
>
> p->max = (size < NGX_MAX_ALLOC_FROM_POOL) ? size :
> NGX_MAX_ALLOC_FROM_POOL;
>
>
> I know, I have created a pool with size 8K, now I am allocating say 4K
> (4096) from this pool. I will call ngx_palloc with 4096. There we check if
> (size <= pool->max) which in this case will not satisfy and it will go and
> call ngx_palloc_large which inturn will allocate 4K.
>
> This somehow is not sounding good. Why is ngx_create_pool putting a max
> value of page size even when it is allocating more. It is not doing chaining
> also.
>
> Any expert opinions???
>
> Thanks, Santos
Hint: allocations not exceeding pool->max are not freed by ngx_pfree()
until the pool is destroyed.
More information about the nginx
mailing list