Manage Memory in SAP jConnect Applications

Use the Statement objects and subclasses, if you notice increased memory use in SAP jConnect applications

  • In SAP jConnect applications, explicitly close all Statement objects and subclasses (for example, PreparedStatement, CallableStatement) after their last use to prevent statements from accumulating in memory. Closing only the ResultSet is not sufficient.

    For example, this statement causes problems:
    ResultSet rs = _conn.prepareCall(_query).execute();
    ...
    rs.close();
    Instead, use:
    PreparedStatement ps = _conn.prepareCall(_query);
    ResultSet rs = ps.executeQuery();
    ...
    rs.close();
    ps.close();
  • Native support for scrollable or updatable scrollable cursors may not be available, depending on the version of SAP Adaptive Server or SAP SQL Anywhere database you are connecting to. To support scrollable or updatable scrollable cursors when not supported natively by the back-end server, SAP jConnect caches the row data on demand, on the client, on each call to ResultSet.next. However, when the end of the result set is reached, the entire result set is stored in client memory. Because this may cause a performance degradation, SAP recommends that you use TYPE_SCROLL_INSENSITIVE result sets only when the result set is reasonably small. SAP jConnect determines if the SAP Adaptive Server connection supports native scrollable cursor functionality and uses it instead of client-side caching. As a result, most applications can expect significant performance gain in accessing out-of-order rows and reduction in client-side memory requirements.