Hello! On Thu, Jan 16, 2014 at 06:22:58PM -0800, Ravi Chunduru wrote:
> Hi Nginx experts, > Thanks for the prompt reply to my earlier email on ngx_reset_pool() > > Now, I am looking into ngx_array.c. I found an issue ngx_array_push(). Here > are the details. > nginx will check if number of elements is equal to capacity of the array. > If there is no space in the memory block, it allocates a new memory block > with twice the size of array and copies over the elements. So far so good. > Assume that pool utility got entirely new memory block then a->pool is not > updated with that of 'pool->current'. > > I got an assumption from the code that a->pool is always the memory block > that has the array elements by seeing the code in ngx_array_push(), > ngx_array_push_n() or ngx_array_destroy() where checks were always done > with pool pointer in array. > > Functionalities issues would come up once there is an array overflow. I > think for every new push of element after first crossing/overflow of the > capacity, nginx will keep on creating new array. Thus it results in wastage > of memory. > > Please let me know if its a issue or correct my understanding. That's expected behaviour. Arrays are implemented in a way that allocates additional memory on overflows, and it's expected to happen. There is a ngx_list_t structure to be used if such additional memory allocations are undesired. Optimization of allocations which uses pool internals is just an optimization and it's not expected to always succeed. -- Maxim Dounin http://nginx.org/ _______________________________________________ nginx-devel mailing list [email protected] http://mailman.nginx.org/mailman/listinfo/nginx-devel
