﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	uname	nginx_version
1594	ngx_palloc.c may save more memory	lwppwl@…		"in nginx-1.12.2 version

the ngx_reset_pool() function in ngx_palloc.c may change better:

when reset the point of the p->d.last, should consider the p whether or not the pool,
when the p is not the pool, should offset sizeof(ngx_pool_data_t) not sizeof(ngx_pool_t),

every small block can save sizeof(ngx_pool_t) - sizeof(ngx_pool_data_t) bytes.

----

'''Original code:'''


{{{
void ngx_reset_pool(ngx_pool_t *pool)
{
    ...
    for (p = pool; p; p = p->d.next)
    {
        p->d.last = (u_char *) p + sizeof(ngx_pool_t);
        p->d.failed = 0;
    }
    ...
}
}}}

'''Suggested code:'''

{{{
void ngx_reset_pool(ngx_pool_t *pool)
{
    ...
    for (p = pool; p; p = p->d.next)
    {
        if (p == pool)
        {
            p->d.last = (u_char *) p + sizeof(ngx_pool_t);
            p->d.failed = 0;
        }
        else
        {
            p->d.last = (u_char *) p + sizeof(ngx_pool_data_t);
            p->d.failed = 0;
        }
    }
    ...
}
}}}
"	defect	closed	minor		other	1.12.x	wontfix			Linux lwp-All-Series 4.15.0-24-generic #26~16.04.1-Ubuntu SMP Fri Jun 15 14:35:08 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux	"nginx version: nginx/1.12.2
built by gcc 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.9) 
configure arguments: --prefix=/data/modules/nginx"
