CalculatedProperties icon indicating copy to clipboard operation
CalculatedProperties copied to clipboard

Feature/fix memory leak

Open DunetsNM opened this issue 8 years ago • 2 comments

There's a memory leak if source property sits on a long living object while target is on a short living object. Simple fix is to wrap target properties in WeakReference

DunetsNM avatar Jun 28 '17 13:06 DunetsNM

used ConditionalWeakTable to improve add/remove performance. List of weak references still needed to iterate alive targets

DunetsNM avatar Jul 03 '17 08:07 DunetsNM

Performance test case:

  1. Initial wiring: Create source with 50,000 immediate targets
  2. Re-wiring: unplug an old target and add a new target, repeat 50,000 times

Results on my machine (Release)

  • with HashSet: 0.2 sec for initial wiring and 0.3-0.4 sec for re-wiring
  • with ConditionalWeakTable: 0.3-0.4 sec for initial wiring and 0.7-0.8 sec for re-wiring

DunetsNM avatar Jul 03 '17 08:07 DunetsNM