{"id":16388946,"url":"https://github.com/chobits/ngx_debug_pool","last_synced_at":"2026-03-13T18:10:22.448Z","repository":{"id":145308668,"uuid":"41983736","full_name":"chobits/ngx_debug_pool","owner":"chobits","description":"get memory usage of nginx memory pool","archived":false,"fork":false,"pushed_at":"2015-11-25T13:01:16.000Z","size":9,"stargazers_count":20,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-18T17:45:03.986Z","etag":null,"topics":["memory-analysis","nginx-memory-pool"],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chobits.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-06T02:29:47.000Z","updated_at":"2024-12-19T13:32:50.000Z","dependencies_parsed_at":"2023-04-14T04:57:06.792Z","dependency_job_id":null,"html_url":"https://github.com/chobits/ngx_debug_pool","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chobits%2Fngx_debug_pool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chobits%2Fngx_debug_pool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chobits%2Fngx_debug_pool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chobits%2Fngx_debug_pool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chobits","download_url":"https://codeload.github.com/chobits/ngx_debug_pool/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245056889,"owners_count":20553855,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["memory-analysis","nginx-memory-pool"],"created_at":"2024-10-11T04:30:26.354Z","updated_at":"2026-03-13T18:10:22.404Z","avatar_url":"https://github.com/chobits.png","language":"C","readme":"ngx_debug_pool\n==============\n\nThis module provides access to information of memory usage for nginx memory pool.\n\nExample\n=======\n\nget information of worker process\n---------------------------------\n\n```\n http {\n    server {\n        listen 80;\n\n        location = /debug_pool {\n            debug_pool;\n        }\n    }\n }\n```\n\nRequesting URI /debug_pool, you will get information of memory usage for worker process which gets this request.  \nThe output page may look like as follows:\n\n```\n$ curl http://localhost:80/debug_pool\npid:1671\nsize:      502312 num:           6 cnum:           1 lnum:          31 ngx_init_cycle\nsize:           0 num:           1 cnum:           0 lnum:           0 ngx_http_spdy_keepalive_handler\nsize:        1536 num:         195 cnum:           1 lnum:        1635 ngx_event_accept\nsize:           0 num:          11 cnum:           0 lnum:           0 ngx_http_upstream_connect\nsize:           0 num:           1 cnum:           0 lnum:           0 ngx_http_lua_create_fake_request\nsize:           0 num:           1 cnum:           0 lnum:           0 main\nsize:           0 num:           1 cnum:           0 lnum:           0 ngx_http_lua_create_fake_connection\nsize:           0 num:           1 cnum:           0 lnum:           0 ngx_http_spdy_init\nsize:           0 num:           3 cnum:           0 lnum:          18 ngx_http_server_names\nsize:        8192 num:         810 cnum:           1 lnum:          11 ngx_http_create_request\nsize:           0 num:           1 cnum:           0 lnum:           0 ngx_http_lua_init_worker\nsize:       500KB num:        1031 cnum:           3 lnum:        1695 [SUMMARY]\n```\n\nget information of specific process\n-----------------------------------\n\nAlso you can use gdb script `debug_pool.gdb` to get information of specific process.  \nSome process cannot handle HTTP request, such as master process or [tengine Proc process](https://github.com/alibaba/tengine/blob/master/docs/modules/ngx_procs_module.md).  \nThe following example shows how to get information of master process.\n\n```\n$ gdb -q -x debug_pool.gdb -p \u003cpid of master process\u003e\n(gdb) debug_pool\nsize:      191016 num:           4 cnum:           1 lnum:          20 ngx_init_cycle:13\nsize:           0 num:           1 cnum:           0 lnum:           0 main:403\nsize:           0 num:           2 cnum:           0 lnum:          12 ngx_http_server_names:751\nsize:      191016 num:           7 cnum:           1 lnum:          32 [SUMMARY]\n```\n\nget information of specific memory pool\n---------------------------------------\nThe gdb script `debug_pool.gdb` provides another function to get information of specific memory pool.  \nThe following example shows memory usage of `ngx_cycle-\u003epool`, which is used for parsing nginx configuration.\n\n```\n$ gdb -q -x debug_pool.gdb -p \u003cpid of nginx process\u003e\n(gdb) pool_size ngx_cycle-\u003epool\nallocated from pool:                    163840 bytes\nallocated via ngx_palloc_large():        27176 bytes\ntotal size:                             191016 bytes\n```\n\nData\n====\n\nEvery line except the last one of output content has the same format, as follows:\n\n\"__size__: %12u __num__: %12u __cnum__: %12u __lnum__: %12u __\\\u003cfunction name\\\u003e__\"\n\n* __size__: size of current used memory of this pool\n* __num__:  number of created pool (including current used pool and destroyed pool)\n* __cnum__: number of current used pool\n* __lnum__: number of calling ngx_palloc_large()\n  * If allocated memory is larger than predefined size of memory pool, nginx will allocate memory via malloc(ngx_alloc) in ngx_palloc_large().\n* __funcion name__: which nginx C function creates this pool\n  * With function name of pool creator, we can know memory usage of every module, for example:\n  * pool created by `ngx_http_create_request` is used for one HTTP request.\n    * Because most modules allocates memory from this pool directly, it's hard to distinguish between them.\n  * pool created by `ngx_event_accept` is used for TCP connection from client.\n  * pool created by `ngx_http_upstream_connect` is used for HTTP connection to upstream peer.\n  * pool created by `ngx_http_spdy_init` is used for SPDY session.\n    * This pool will be freed and recreated by `ngx_http_spdy_keepalive_handler` when spdy connection goes idle.\n  * pool created by `ngx_init_cycle` is used for parsing nginx configuration and keeping other global data structures.\n  * pool created by `ngx_http_lua_init_worker` is used for conf.temp_pool of directive [init_worker_by_lua](https://github.com/openresty/lua-nginx-module#init_worker_by_lua).\n  * ...\n\nLast line of output content summarizes the information of all memory pools.\n\nNginx Compatibility\n===================\n\nThe latest module is compatible with the following versions of nginx:\n\n* 1.8.0 (stable version of 1.8.x)\n* 1.6.3 (stable version of 1.6.x)\n* 1.4.7 (stable version of 1.4.x)\n* 1.2.9 (stable version of 1.2.x)\n\nTengine Compatibility\n=====================\n\nThis module has been merged into tengine, see this [pull request](https://github.com/alibaba/tengine/pull/638).\n\nInstall\n=======\n\nInstall this module from source:\n\n```\n$ wget http://nginx.org/download/nginx-1.8.0.tar.gz\n$ tar -xzvf nginx-1.8.0.tar.gz\n$ cd nginx-1.8.0/\n$ patch -p1 \u003c /path/to/ngx_debug_pool/debug_pool.patch\n$ ./configure --add-module=/path/to/ngx_debug_pool\n$ make \u0026\u0026 make install\n```\n\nNote that `debug_pool.patch` includes memory tracking logic in macro NGX_DEBUG_POOL, and [config](config) will enable this macro automatically.\n\nDirective\n=========\n\nSyntax: **debug_pool**\n\nDefault: `none`\n\nContext: `server, location`\n\nThe information of nginx memory pool usage will be accessible from the surrounding location.\n\nException\n=========\n\nMemory allocated without using memory pool does not get taken into account with this module.  \nFor example,\n* [ngx_http_spdy_module](http://nginx.org/en/docs/http/ngx_http_spdy_module.html) allocates a temporary buffer via malloc(ngx_alloc) for raw data of SYN_REPLY frame. After being compressed, this buffer will be freed immediately.\n* All lua internal objects of Lua/LuaJIT used by [lua-nginx-module](https://github.com/openresty/lua-nginx-module) are allocated/freed via malloc/free. So the information of Lua/LuaJIT memory usage cannot be accessed from this module. \n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchobits%2Fngx_debug_pool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchobits%2Fngx_debug_pool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchobits%2Fngx_debug_pool/lists"}