Pattern-Oriented Software Architecture Volume 3: Patterns for Resource Management
by Michael Kircher, Prashant Jain
4 Resource Release
“I saw the angel in the marble and carved until I set him free.”
Michelangelo Buonarroti
Timely release of resources that are no longer being used is essential in maintaining system stability and avoiding cases of resource exhaustion. Optimizing the release of resources is beneficial, as system performance and scalability depend directly on it. If reusable resources have to be acquired repeatedly, overhead is incurred. If the resources are not freed when no longer needed, it can lead to resource starvation. This in turn can lead to system instability and degrade scalability of the system.
Releasing resources explicitly can be tedious and sometimes error-prone. Both the Leasing (149) pattern and the Evictor (168) pattern address resource release by ensuring that acquired reusable resources are released in a timely manner. The Leasing pattern simplifies resource release by associating time-based leases with resources when they are acquired. The resources are automatically released when the leases expire and are not renewed. The Evictor pattern deals with determining when to release resources and which resources to release. The patterns together help to optimize the number of acquired resources at any point in time.
Leasing
The Leasing pattern simplifies resource release by associating time-based leases with resources when they are acquired. The resources are automatically released when the leases expire and are not renewed.
Example
Consider a system consisting ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access