# Different Resource Management Constructs
- Manual resource management - `malloc` and `free`, but applies to any process where resources are manually deleted (ex: closing a database connection).
- [[Garbage Collection]]. However, if we're dealing with non-memory resources, other constructs are necessary.
- Garbage collection over non-volatile resources is a fascinating topic; Example: https://www.warpstream.com/blog/taking-out-the-trash-garbage-collection-of-object-storage-at-massive-scale
- [[Ownership]], [[Rust]], but Including C++'s [[Ownership|RAII]].
- [[Reference Counting]] - can see this as an ownership construct or a garbage collecting construct.
- Syntactical constructs:
- `withResource<T>((res) => T)` - (has the name of the "loan pattern" #design-pattern). Useful if there are no language level constructs.
- decorators ([[Python]]). Similar to the loan pattern, but is more "declarative".
- [[Defer]] statements. This isn't that different than `try-finally`, except it is syntactically more concise.
- [[Python - with statement|Resource Block]] in [[Java]] / [[Python]]. i.e. `with` statements.
- `using` in [[Csharp|C#]] / [[TypeScript]] - [[TC39 Explicit Resource Management]]