|Incorrect(?) retained heap for com.google.common.base.Optional [message #1234658]
||Wed, 22 January 2014 13:53
| Lars Oppermann
Registered: January 2014
While debugging a memory problem I found a leak where some domain objects pile up in a HashMap. The domain objects are wrapped in a com.google.common.base.Optional (google guava library) and the value fields of the HashMap$Entry instances are of type com.google.common.base.Optional$Present.
The retained heap for the reference field in those instances shows correctly as 6,750,112 bytes. However, this is not added to the retained heap of the HashMap or any other instances further up the object tree in which it is included.
In this case, it was pretty easy to find these objects since they are relatively large (> 6MB), but in scenarios where the individual instances are much smaller and just much more numerous, I wasn't able to see the problem because the where not attributed to the retained heap.
Here is a (redacted) screenshot showing the situation for one of the 700+ HashMap entries. All of the entries include a similar value:
Am I wrong in expecting that these "com.foo.bar.LargeDomainObject" instances should normally be part of the retained heap of the containing HashMap?
Powered by FUDForum
. Page generated in 0.02244 seconds