WPF properties memory management

Posted by mrpyo on Programmers See other posts from Programmers or by mrpyo
Published on 2014-05-28T14:24:32Z Indexed on 2014/05/28 22:02 UTC
Read the original article Hit count: 386

Filed under:
|
|

I'm trying to build binding system similar to the one that is used in WPF and I ran into some memory leaking problems, so here comes my question - how is memory managed in WPF property system?

From what I know in WPF values of DependencyProperties are stored in external containers - what I wanna know is how are they collected when DependencyObject dies?

Simplest solution would be to store them is some weak reference dictionary - but here comes the main problem I ran into - when there is a listener on property that needs reference to its (this property) parent it holds it (the parent) alive (when value of weak reference dictionary points somewhere, even indirectly, to key - it can't be collected).

How is it avoided in WPF without the need of using weak references everywhere?

© Programmers or respective owner

Related posts about c#

Related posts about wpf