memory pool allocation

nginxsantos nginx-forum at
Wed Apr 9 12:31:29 UTC 2014

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 :

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

Any expert opinions???

Thanks, Santos

Posted at Nginx Forum:,249161,249161#msg-249161

More information about the nginx mailing list