ACE (C++):没有调用cancel_timer == MLK?
如果通过cancel_timer安排一次性计时器
schedule_timer(timer,0,ACE_Time_Value(delay),ACE_Time_Value::zero)
以避免内存泄漏?
If a one-shot timer was scheduled via
schedule_timer(timer,0,ACE_Time_Value(delay),ACE_Time_Value::zero)
is cancel_timer required in order to avoid a memory leak?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为答案是“视情况而定”。 除了相对古老的 ACE 版本之外,您可以让 Reactor(或 Timer_Queue)增加事件处理程序的引用计数,并在事件处理程序从 Reactor(或 Timer_Queue)中删除时减少引用计数。
请注意,引用计数是可选的,并且必须启用。
另外,这个东西我没用过,看文档并测试一下!
I think the answer is "it depends". With anything but relative ancient versions of ACE, you can have the Reactor (or Timer_Queue) increase the reference count on your event handler, and decrement it when the event handler is removed from the Reactor (or Timer_Queue.)
Please notice that reference counting is optional, and has to be enabled.
In addition, I have not used this stuff, read the documentation and test!
ACE 不会释放计时器对象,但 ACE 维护计时器所需的任何数据结构都会在计时器运行后被释放。
有两种方法可以验证这一点:
The timer object will not be released by ACE, but any data structure needed by ACE to maintain the timer will be released after the timer is run.
Two ways to verify this: