Retained sizes calculated incorrectly

Questions about YourKit Java Profiler
Post Reply
fitermay
Posts: 3
Joined: Fri Jun 17, 2016 8:05 pm

Retained sizes calculated incorrectly

Post by fitermay »

Image

How can retained size of a container be less than the retained size of the contained object if it's the only strong reference to it?
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Retained sizes calculated incorrectly

Post by Anton Katilin »

Retained sizes are calculated with any references: strong, weak, soft.
If a container's retained size is less than the retained size of its content, this means that the container does not retain its content which is referenced from some other object via any kind of reference.
fitermay
Posts: 3
Joined: Fri Jun 17, 2016 8:05 pm

Re: Retained sizes calculated incorrectly

Post by fitermay »

Weak and soft references should be excluded when calculating retained sizes. Otherwise it is not a very useful metric.
fitermay
Posts: 3
Joined: Fri Jun 17, 2016 8:05 pm

Re: Retained sizes calculated incorrectly

Post by fitermay »

Most certainly weak references never retain their contents. So they should absolutely be excluded during the calculation. Soft references MAY retain their contents, but the metric is more useful with them excluded or maybe two metrics should be provided with soft and without.
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: Retained sizes calculated incorrectly

Post by Anton Katilin »

To ignore soft and weak references please specify -Dyjp.keep.weak.refs=false and -Dyjp.keep.soft.refs=false in <user home>/.yjp/ui.ini
You'll need to delete *.snapshot.idom files before restarting the profiler UI to ensure the change is applied. The snapshot directory is <user home>/Snapshots
Post Reply