Unregistered event handlers cause memory leak

前端 未结 2 1561
有刺的猬
有刺的猬 2020-12-30 10:52

I\'m maintaining a web application that has a memory leak.

Based on my investigation using Red Gate ANTS memory profiler I\'m pretty sure that the memory leak is cau

2条回答
  •  一个人的身影
    2020-12-30 11:18

    The Dispose method on the collection should be called directly by your code because the event holds a reference to the collection. Your collection will never be destroyed by garbage collector.

    You should also change the behaviour of the Remove and Clean methods of the collection to detach the event handler from the removed items.

提交回复
热议问题