-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
解决内存使用上的一些问题 #34
base: master
Are you sure you want to change the base?
解决内存使用上的一些问题 #34
Conversation
Sunldon
commented
Sep 19, 2024
- master进程中调用了ngx_http_health_detect_add_or_update_node_on_local,并创建了内存池 temp_pool = ngx_create_pool(...); 当reload nginx时,这部分内存分配的node节点不会释放,会继续创建新的内存池,继续新的分配。解决办法是在ngx_http_health_detect_create_main_conf中调用ngx_http_health_detect_clear_peers_events进行释放内存
- 先打印相关信息,再进行free_node,避免内存释放后还继续使用
…了内存池 temp_pool = ngx_create_pool(...); 当reload nginx时,这部分内存分配的node节点不会释放,会继续创建新的内存池,继续新的分配。解决办法是在ngx_http_health_detect_create_main_conf中调用ngx_http_health_detect_clear_peers_events进行释放内存 2. 先打印相关信息,再进行free_node,避免内存释放后还继续使用
你好,想问下这个mr有经过测试吗? 从代码结构上看,ngx_http_health_detect_create_main_conf 一般只适合做一些配置相关的工作,像ngx_http_health_detect_clear_peers_events这种业务性的代码不适合放在ngx_http_health_detect_create_main_conf中,另外ngx_http_health_detect_create_main_conf中调用 ngx_http_health_detect_clear_peers_events 应该也没什么效果,因为拿不到上次的本地节点信息。 |
你说的这个问题可能存在,方便的话可以描述一下你那边看到的问题现象。 针对这个问题,目前的想法是:
相关修改见 #37 有时间可以review此PR, 或者直接做出调整并提交PR。 |
|
hello 针对以上几点,我们进一步展开讨论:
针对第3点: 只有静态节点才会使用cf->pool中的内存,会持久占用内存,但一般静态的节点不会频繁删除,而且数量有限,所以内存占用是可以接受的,如果是动态增删的节点,还是使用自己申请的内存pool,不会使用cf->pool。 针对第4点: 你说的很对,建议另起一个mr,提交相关修改, 这样对sanitize这种内存管理工具更加友好。 最后,看到您使用了 sanitize 来检查,方便的话可以提交一个mr,修改编译流程以及README.md,增加sanitize编译选项支持,默认不使用sanitize编译,感谢! |
第二点,我的配置是:
是否你是针对你新修改的代码进行测试的,有这一个条件导致无法进入!peer->using_cf_pool,否则新增的打印destroy pool是可以打印出来的。
第三点,可能我没有描述清楚动态增加节点的情况,我是用这个健康检查的模块,是配合使用动态域名解析的模块的(https://github.com/Sunldon/nginx-http-upstream-dynamic-servers) |
hello,
|
那这个方案也是可以的 |