Java Resource Management

Deterministic release of what a Java program holds open: try-with-resources and the exception semantics that make it non-optional, designing an AutoCloseable (ownership, idempotent close, close that fails), decorators and partially constructed resource chains, resources that cross an async or executor boundary, and the difference between closing a resource and returning one to a pool. Use when a close sits in a finally block, when a resource is created inside a try block or inside a lambda that outlives it, when a method closes something it was handed, when connections or file descriptors leak under load, when ExecutorService or StructuredTaskScope is used in try-with-resources, or when a stream from Files.lines or Files.walk is never closed. Does not cover reachability-driven cleanup — WeakReference, SoftReference, Cleaner and the leaks they hide (java-reference-types-and-leaks) — pool sizing (connection-pool-sizing), or native segment lifetimes (off-heap-memory).

robsonkades 85f72a9 4 files · 27.0 KB Updated

File contents

robsonkades/agent-skills/tree/main/skills/java-resource-management commit 85f72a9dcd

Frequently asked questions

npx skillmds@latest add robsonkades/java-resource-management