nginx-模块内存泄露调试
生活随笔
收集整理的這篇文章主要介紹了
nginx-模块内存泄露调试
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
在開發或使用別人模塊時,偶爾會出現內存泄露的情況,這個時候在配置文件中配置
worker_processer 1;
daemon off;
master_process off;
然后使用valgrind調試:
valgrind --leak-check=yes --log-file=valgrind_result_leak --trace-children=yes ./nginx
然后出現如下結果:
==29006== 355,213,312 bytes in 86,722 blocks are possibly lost in loss record 145 of 145 ==29006== at 0x4A0610C: malloc (vg_replace_malloc.c:195) ==29006== by 0x42C745: ngx_alloc (ngx_alloc.c:22) ==29006== by 0x41636B: ngx_palloc_large (ngx_palloc.c:223) ==29006== by 0×416476: ngx_palloc (ngx_palloc.c:142) ==29006== by 0x417EC1: ngx_create_temp_buf (ngx_buf.c:22) ==29006== by 0x49F8E9: ngx_tcp_lua_chains_get_free_buf (ngx_tcp_lua_util.c:623) ==29006== by 0x4A518A: ngx_tcp_lua_socket_tcp_receive (ngx_tcp_lua_socket.c:1150) ==29006== by 0x4C27A02: lj_BC_FUNCC (in /usr/local/nginx/luajit1/lib/libluajit-5.1.so.2.0.0) ==29006== by 0x49FB1F: ngx_tcp_lua_run_thread (ngx_tcp_lua_util.c:386) ==29006== by 0x49FCC5: ngx_tcp_lua_wev_handler (ngx_tcp_lua_util.c:517) ==29006== by 0x4A0BBF: ngx_tcp_lua_socket_handle_success (ngx_tcp_lua_socket.c:2009) ==29006== by 0x4A487D: ngx_tcp_lua_socket_read (ngx_tcp_lua_socket.c:1395)很容易看出,問題出現在ngx_tcp_lua_chains_get_free_buf獲得的內存沒有釋放。
總結
以上是生活随笔為你收集整理的nginx-模块内存泄露调试的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Redis Monitor命令 - 实时
- 下一篇: nginx下使用asan和valgrin