Opened 10 years ago

Closed 10 years ago

#490 closed defect (fixed)

ngx_reset_pool() memory wastage

Reported by: Ravi Chunduru Owned by:
Priority: minor Milestone:
Component: nginx-core Version:
Keywords: Cc:
uname -a:
nginx -V: all versions

Description

ngx_reset_pool() seems to free up large buffers and sets d.last to start of available memory location.

for (p = pool; p; p = p->d.next) {

p->d.last = (u_char *) p + sizeof(ngx_pool_t);

}

But it does not reset p->d.failed to zero and does not set p->d.current= pool for the first memory block.
Now that p->d.current points to the latest memory block in the pool, all the previous memory blocks in the pool go wasted.

Change History (2)

comment:1 by Maxim Dounin <mdounin@…>, 10 years ago

In 320abeb364e697f86d080616de07ad09080aaea9/nginx:

Core: improved ngx_reset_pool() (ticket #490).

Previously pool->current wasn't moved back to pool, resulting in blocks
not used for further allocations if pool->current was already moved at the
time of ngx_reset_pool(). Additionally, to preserve logic of moving
pool->current, the p->d.failed counters are now properly cleared. While
here, pool->chain is also cleared.

This change is essentially a nop with current code, but generally improves
things.

comment:2 by Maxim Dounin, 10 years ago

Resolution: fixed
Status: newclosed

Fix committed, thanx.

Note: See TracTickets for help on using tickets.