Because of a Java Heap Space
error I did a heap dump of my Java EE 7
program running on a WildFly 9
server. Then I used Eclipse Memory Analyser
to analyse the dump. Eclipse Memory Analyser
reveals the 2 following problems which are the same:
One instance of "org.jboss.as.ejb3.component.stateful.StatefulSessionComponent" loaded by "org.jboss.modules.ModuleClassLoader @ 0xe0130378" occupies 168 975 304 (36,60%) bytes. The memory is accumulated in one instance of "java.util.concurrent.ConcurrentHashMap$Node[]" loaded by "".
One instance of "org.jboss.as.ejb3.component.stateful.StatefulSessionComponent" loaded by "org.jboss.modules.ModuleClassLoader @ 0xe0130378" occupies 155 775 312 (33,74%) bytes. The memory is accumulated in one instance of "java.util.concurrent.ConcurrentHashMap$Node[]" loaded by "".
I have few Stateful EJBs on my program. Does that mean those EJBs are never garbage collected ? Any idea how to solve this problem ?
EDIT
Here a capture of the dominator tree:
It seems that the class
java.util.concurrent.ConcurrentHashMap$Node
is the cause.