Systems Programming · Cluster
Resource Management
Ownership, leaks, and deterministic cleanup.
- 01 Release Order at Scope Exit and the LIFO Cleanup Rule Why destructors, defer statements, and scope guards run in reverse order of acquisition, and which ordering guarantees survive partial construction and unwinding.
- 02 Failure Atomicity and Cleanup on the Error Path How partial construction is made safe: commit-or-rollback discipline, errdefer-style compensation, and the invariants a constructor must restore before returning an error.
- 03 Move Semantics and the State Left Behind in the Source What transferring ownership actually changes in memory, why a moved-from object must still be destructible, and how unique ownership differs from a shallow copy.
- 04 Atomic Reference Counts and the Cycle They Cannot Collect The instruction cost of shared ownership, why the count must be atomic, and the reachability problem that makes a pure reference-counting collector leak.
- 05 Leak Detection by Reachability Rather Than Allocation Count How heap profilers decide that a block is leaked: root sets, conservative scanning, and why a pointer held in a register or a stale stack slot changes the answer.
- 06 File Descriptor Lifetime, Inheritance, and Table Exhaustion What a descriptor actually indexes, how the process and system tables share file descriptions, and why closing in the wrong process leaves the resource open.
- 07 Arena Allocation and the Cost of Releasing Everything at Once Bump allocation, region lifetimes, and why destroying a whole arena is cheaper than freeing its objects, together with the reuse patterns that keep it from growing.
- 08 Finalizers and the Gap Between Reclaimable and Released Why a finalizer runs at an unpredictable time, how resurrection and finalizer ordering break cleanup, and what a disposal protocol adds that collection cannot.
- 09 Cancellation Points and the Half-Finished Cleanup State How asynchronous cancellation, unwinding, and cooperative cancellation interact with cleanup code, and why a cleanup routine must be reentrant against itself.
- 10 Ordered Shutdown, Exit Handlers, and What the Kernel Reclaims Why exit handlers run in reverse order with no error reporting, what survives a call to _exit, and how to drain work before the kernel releases descriptors and mappings.