Discrepancy in retained byte for nested wpf controls in Memory profiler

Hello.

I use memory profiler to find memory leaks.

I found it but i run into curious situation. I learn out that 2 my wpf controls stay in memory after closing.

Let's named it ParentControl and Child Control. ParentControl has Child control in its xaml directly (without ContentPresenter and templates).

And into UI i see that "Minimum retained bytes" for Parent is 5 Mb and for child is almost 9 Mb.

Why is it more for child?

0
1 comment
Official comment

Hi,
Since you are talking about "Minimum retained bytes" I guess there are more than one Parent and Child objects. And there are three possible answers

1. There are more instances of Child then instances of Parent and in total they retained more then all instances of Parent in total.
2. "Minimum retained bytes" is not exact number it is the bottom score since calculating objects exclusively retained by any object set is too expensive. You can open all Parent objects set and all Child objects set separately and then use "Open objects retained by this set" placed in the header of investigated object set-  dotMemory shows you exact objects set exclusively retained by "this" set.
3. More likely answer: instance of Child is not exclusively retained by Parent, in this case it is possible that Child exclusively retains more than Parent.

You can read about exclusive retention (domination, in terms of graphs theory) here
https://www.jetbrains.com/help/dotmemory/Retained_by.html

Do not hesitate to ask me if you have any questions

Please sign in to leave a comment.