I'm upgrading my version of JBoss, java and hibernate from
JBoss 6 to wildfly 11
hibernate 4 to hibernate 5.1
and java 6 to java 8
but I'm facing this problem with the java heap, the 79% of the memory is occupated by the ConcurrentHashMap object, I did a heap dump and with eclipse analyzer and I saw that the major error comes from this error
"The classloader/component "org.jboss.modules.ModuleClassLoader @ 0x6c27d1230" occupies 2.877.603.336 (79,10%) bytes. The memory is accumulated in one instance of "java.util.concurrent.ConcurrentHashMap$Node[]" loaded by "system class loader".
and if I see the details, the Accumulated Objects in Dominator Tree show this:
org.jboss.modules.ModuleClassLoader -> 2.877.603.336 (Retained Heap)
-java.util.Vector @ 0x6c27d4db0 -> 2.877.123.872 (Retained Heap)
--java.lang.Object[20480] -> 2.877.123.840 (Retained Heap)
---class org.hibernate.internal.SessionFactoryRegistry -> 2.840.910.848 (Retained Heap)
-----org.hibernate.internal.SessionFactoryRegistry -> 2.840.910.168 (Retained Heap)
------java.util.concurrent.ConcurrentHashMap -> 2.840.909.848 (Retained Heap)
-------java.util.concurrent.ConcurrentHashMap$Node[256]-> 2.840.909.784 (Retained Heap)
I really don't understand why this happens, because using the old technologies, not one this happen.
At the end was a bug in the code, i had a "reconnect" for every time that i had a NOT_ACTIVE status, this reconnect build new connections and generate a memory leak in the application.
Removing this reconnect and excluding the NOT_ACTIVE status was the solution for this problem.