apache线程的apr_pool_destroy()安全吗?
我的应用程序是用 apache 构建的并在 Windows 上运行。我使用 createThread() 创建一个线程,然后为每个线程执行以下操作:
ap_run_sub_req( subrequest );
ap_rflush( subrequest );
ap_destroy_sub_req( subrequest );
ap_destroy_sub_request 依次调用 apr_pool_destroy() 函数。
ap_run_sub_req() 为池分配内存, ap_destroy_sub_req() 释放分配的内存。
如果 apr_pool_destroy() 在线程内调用,则分配的内存不会被释放,导致我的应用程序出现内存泄漏。我在任何 apache 文档中都找不到任何提及 apr_pool_destroy() 是非线程安全函数的内容。
这个问题如何解决?如何释放线程内分配的池?
谢谢
My application is built with apache and runs on windows. I am creating a Thread using the createThread() and then for each thread executing the below :
ap_run_sub_req( subrequest );
ap_rflush( subrequest );
ap_destroy_sub_req( subrequest );
The ap_destroy_sub_request in turn calls apr_pool_destroy() function.
The ap_run_sub_req() allocated memory for pool and ap_destroy_sub_req() frees the allocated memory.
If the apr_pool_destroy() is called inside a thread then the allocated memory is not freed as a result my application is having memory leak. I couldn't find in any apache documentation any mention of apr_pool_destroy() being non-thread safe functions.
How can this problem be resolved ?? How can I free the allocated pool inside the threads?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是
apr_pool_destroy()
的源代码:从它的外观来看,它不是线程安全的,但我不是C专家。您可能应该在APR 邮件列表上发帖。
Here's the source code for
apr_pool_destroy()
:From the looks of it, it's not thread-safe, but I'm not a C expert. You should probably post on the APR mailing list.