mirror of
https://github.com/nginx/nginx.git
synced 2026-02-03 20:29:27 -05:00
Core: trim malloc memory after configuration unload.
When using dynamic configurations, multiple malloc arens could be created because of using threads. Also, a worker process may persist through multiple dynamic cycles which increases memory fragmentation. Both these factors contribute to malloc not being able to effectively free its memory to the kernel, which increases overall system memory consumption despite only a small amount of memory being allocated from malloc(). To enfoce memory release, malloc_trim() is now called after cycle unload.
This commit is contained in:
parent
9d9b3785c1
commit
dd22d6ed11
2 changed files with 14 additions and 0 deletions
10
auto/unix
10
auto/unix
|
|
@ -833,6 +833,16 @@ ngx_feature_test="void *p; p = memalign(4096, 4096);
|
|||
. auto/feature
|
||||
|
||||
|
||||
ngx_feature="malloc_trim()"
|
||||
ngx_feature_name="NGX_HAVE_MALLOC_TRIM"
|
||||
ngx_feature_run=no
|
||||
ngx_feature_incs="#include <malloc.h>"
|
||||
ngx_feature_path=
|
||||
ngx_feature_libs=
|
||||
ngx_feature_test="malloc_trim(0)"
|
||||
. auto/feature
|
||||
|
||||
|
||||
ngx_feature="mmap(MAP_ANON|MAP_SHARED)"
|
||||
ngx_feature_name="NGX_HAVE_MAP_ANON"
|
||||
ngx_feature_run=yes
|
||||
|
|
|
|||
|
|
@ -864,6 +864,10 @@ ngx_dynamic_conf_unload(ngx_dynamic_conf_ctx_t *ctx)
|
|||
ctx->cycle, ctx->id);
|
||||
|
||||
ngx_destroy_pool(ctx->pool);
|
||||
|
||||
#if (NGX_HAVE_MALLOC_TRIM)
|
||||
malloc_trim(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue