知秋一叶

日出而作,日入而息,凿井而饮,耕田而食,帝力何有于我哉
随笔 - 55, 评论 - 311, 引用 - 79

导航

工具

标签

每月存档

广告



访客

 

  I have been thinking about the notion of “Weak Delegate” for a long time. For those who don't want to remove (-=) the delegate everytime, here is a thorough description about the potential memory leak problem and the solution and sample code by Greg Schechter.  And here is a generic version by Ian Griffiths.
  Be advised: Weak Delegate or not, A Memory Leak is a memory leak. You should ALWAYS remember to remove the eventhandler once the listener is out of scope.

相关文章

Loading...

打印 | 张贴于 2004-09-22 03:59:00 | Tag:.NET

留言反馈

#re:Weak Delegate 编辑
Weak Delegateooeess
2005-06-14 10:19:00 | [匿名用户:一氧化碳测定仪]
#re:Weak Delegate 编辑
^_~,pretty good!csharpsseeoo
2005-05-16 16:54:00 | [匿名用户:元件测试仪]
#re:Weak Delegate 编辑
^_^,Pretty Good!
2005-04-16 01:38:00 | [匿名用户:螺杆泵]
#re:Weak Delegate 编辑
^_^,Pretty Good!
2005-04-10 19:56:00 | [匿名用户:邵氏硬度计]
#re: Weak Delegate 编辑
I think the general Dispose -> SuppressFinalizer -> Finalizer pattern still fits here. Anyway, having to remember to destroy something is a pain in an environment like .Net. :(
2004-09-22 10:41:00 | [匿名用户:qqchen]
#re: Weak Delegate 编辑
What is the best time to remove the event handlers in a typical windows or web appilication? Dispose()? Finalize()?
2004-09-22 08:54:00 | [匿名用户:Ninputer]
对不起,目前本随笔不允许发表新评论.

Powered by: Joycode MVC Blogger System