JBoss - Java heap retention in WrapperDataSourceService's resultSetMap
Environment
- JBoss Enterprise Application Platform (EAP)
Issue
- "java.lang.OutOfMemoryError: Java heap space" errors are received because the heap is consumed by many instances of org.jboss.resource.adapter.jdbc.WrappedResultSet
- The WrappedResultSet objects are all being retained in org.jboss.resource.adapter.jdbc.remote.WrapperDataSourceService's resultsSetMap
Resolution
-
Be sure all result sets are properly closed.
-
The impact of leaked result sets could be mitigated by no longer accessing a datasource remotely. Remote datasource access is not recommended and there are many other reasons not to do it as described in Access JDBC datasource remotely in JBoss EAP
-
JBoss can track statements and resultSets similar to how it can track connections to provide some back up clean up. As a workaround, you can try adding the following to your datasource config so JBoss will help do resultset cleanup, allowing them to be removed from the heap:
<track-statements>true</track-statements>
Root Cause
- Remote datasource access causes these result sets to be kept in this map until closed. If the result set is not closed, they will persist in this map and the heap.
Diagnostic Steps
- Troubleshoot with a heap dump as described in Java application "java.lang.OutOfMemoryError: Java heap space" to identify the source of retention
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.