Is there any chance that memory leak can occur by using Dependency property binding or Styles. It is showing weak reference in Memory profiling tool and if i remove the binding or style weak reference is not there?. Any idea what will be the cause of that memory leak?
Asked
Active
Viewed 431 times
0
-
1See a related question here on SO: http://stackoverflow.com/questions/516617/what-is-the-weak-event-pattern-used-in-wpf-applications – Simon Mourier Mar 30 '11 at 06:07
1 Answers
1
Not that I have ever detected. And I've used WPF to build some pretty complex 3D UI's.
Weak References are kept until the system needs to garbage collect the location. It is an optimization issue, not a memory leak. The usage of weak references mean that the coder thinks that an object is nice to have around (i.e. sort of cached), but is also OK not to have around (can reload it). So it is up to the .NET runtime to decide when to reclaim a weak-referenced object.
Quite a few WPF constructs are implemented using weak references (I believe triggers and stuff).

Stephen Chung
- 14,497
- 1
- 35
- 48