Terracotta EhCache - concurrent modification creates huge byte array during serialization

262 Views Asked by At

If my heapdump Dominator Tree view looks like below, can I assume the major contributor (~1GB) to my heap is the Thread instance created by Weblogic? And in that Thread a reference to ByteArrayOutputStream is the reason for 1GB?

enter image description here

Follow up question: Can I also assume it is due to object serialization? Maybe triggered by Terracotta ehcahce (from the third line. Not because it is next to the ByeArrayOS, because in our code that is the only place serialization can happen)?

2

There are 2 best solutions below

10
Louis Jacomet On BEST ANSWER

Ehcache does indeed rely on Java Serialization the moment your cache goes beyond heap.

However, it will only ever serialize what you put in the cache. So is it possible that some cached mappings have such huge value or even key?

2
Henri On

The Dominator tree is saying that you have a Weblogic thread holding a ByteArrayOutputStream (and a SerializerObjectOutputStream). The Weblogic thread is a classical worker thread currently processing a request. And it is currently stuck on something.

So, this is the equivalent of

ByteArrayOutputStream in = new ByteArrayOutputStream();
Thread.wait();

The thread is holding a ByteArrayOutputStream and it can't be garbage collected since the thread isn't done with it.

Seeing the serializer makes me think that you are currently deserializing from Ehcache disk or offheap.

Is it possible that you are putting pretty huge objects in your cache? As @louis-jacomet mentioned noticed.