Finalizador
Finalizador is a programming concept referring to a routine that runs cleanup code when an object is slated for destruction. In languages with garbage collection, a finalizador is a method or mechanism by which the runtime attempts to release resources that are not managed by the language itself, such as native handles, file descriptors, or unmanaged memory. The term is closely related to, but not identical with, a destructor, which in some languages denotes deterministic destruction.
Timing and guarantees: Finalizadores are generally non-deterministic. The runtime decides when to run them, and there
Language patterns and examples: In Java, a finalizer method named finalize() can be defined, but it has
Best practices: Prefer explicit, deterministic cleanup whenever possible (Dispose/close/exit patterns, using blocks, context managers). Use finalizers
See also: destructor, garbage collection, IDisposable, AutoCloseable, context manager.