Possible Performance Hits from Event Handlers and Callbacks
If a delegate uses an instance callback method, then the delegate contains an implicit this pointer, where this is the instance of the class A containing the callback methed. When a garbage collection occurs, the instance of the class A remains reachable from a rooted reference if the delegate instance is reachable. To allow a GC collects the instance of the class A, make the callback function static.
Adopted from Debug Leaky Apps: Identify And Prevent Memory Leaks In Managed Code by James Kovacs.
Labels: Performance
0 Comments:
Post a Comment
<< Home