JBoss - Java heap retention in WrappedCallableStatements

Solution Verified - Updated

Environment

  • JBoss Enterprise Application Platform (EAP)
    • 5.x
    • 6.x

Issue

  • We see high heap usage by accumulating WrappedCallableStatement objects. These are retained in the statements map of a WrappedConnection Object.

Resolution

  • Close the connection and statements opened against the connection will be cleaned up as well
  • This indicates though that statement objects are not being closed. Be sure to close a statement when done with it. It would be best to do that in a finally block so that prior exceptions do not inadvertently cause you to skip over the close calls.

Root Cause

  • Datasource connections are being checked out and are not ever closed or are kept open for long lengths of time. Many statements are also opened from these connections, but never closed.
Components
Category

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.