Resource Management

Resource Management

Use CPU, memory, and storage efficiently

Enforceable guidelines from our catalog

Resources Must Be Managed with Try-With-Resources

All resources implementing AutoCloseable (files, database connections, network sockets) must be managed using try-with-resources statements to ensure automatic resource cleanup and prevent resource leaks even when exceptions occur.

Database Connection Pools Must Be Properly Sized

Database connection pools using HikariCP, Apache DBCP, or Tomcat JDBC must be sized based on application load patterns and system resources, with monitoring for pool exhaustion using JMX or Micrometer metrics and appropriate overflow handling.

Connection Pools Must Implement Health Checks

Connection pools must implement validation queries, connection testing on borrow/return using HikariCP’s connectionTestQuery or DBCP’s validationQuery, and connection lifetime management to detect and replace stale or broken connections.

Sign up for free
and get unlimited access to our guidelines catalog