SQLWarning instances associated with JDBC connections consuming memory in EAP 6

Solution Verified - Updated

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 6
    • 7
    • 8
  • All Databases

Issue

Reviewing the memory usage histogram/heap for the application, a high volume of memory is associated with SQLWarning instances

Resolution

One or more of the following may be done to address the issue:

  • Address the condition identified by the warning so that the warning is no longer raised
  • Explicitly clear the warning(s) using the clearWarnings() method for the relevant instance (Connection, PreparedStatement, etc.)
  • Allow the connection to timeout and memory will be freed when the connection is closed
  • Flush connections as described in How to flush a datasource connection pool in EAP to release their accumulated warnings overhead

Root Cause

  • Warnings may be raised by the underlying JDBC driver as the result of activity using connections, statements and result sets
  • Because connections and statements (specifically PreparedStatement instances which are cached by connections) may have a long life cycle, memory may accumulate if not explicitly cleared

Diagnostic Steps

Obtain a heap dump and confirm:

  • The text of the warning(s)
  • The class which directly owns the warnings (e.g. a class implementing Connection, PreparedStatement, ResultSet, etc.)
    • Since connections "own" statements and statements "own" result sets, memory associated with one may impact the retained heap of others
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.