Memory & GC
Reveal answer and reasoning
When a finalizable object becomes unreachable through ordinary application roots, its finalizer may still need access to its fields. The runtime therefore cannot immediately reclaim its storage as though it were an ordinary dead object. Finalization infrastructure keeps the object and relevant reachable graph available until the finalizer runs. A large managed payload referenced by a small wrapper can consequently survive beyond the application's last ordinary owner.
After finalization finishes without resurrection, the object can become eligible for reclamation in a later collection. This is why one collection and one finalizer execution are not the same event as final physical reclamation. An object can also survive for unrelated reasons, such as another strong root. Do not diagnose every long-lived wrapper as a finalizer backlog without inspecting queue state, object graphs and the actual workload.
A finalizer that publishes this into a static location creates a new strong ownership path. That resurrection changes the lifetime story and can expose partially cleaned-up state. Re-registering for finalization adds further complexity. These mechanisms exist, but ordinary application design should prefer a clear deterministic release protocol rather than relying on resurrection to manage useful work.
Finalizers should avoid depending on another finalizable object's cleanup order, performing unbounded blocking work or allowing exceptions to escape. A single problematic finalizer can delay other cleanup. SafeHandle is the standard building block for many native-handle wrappers because it centralizes the resource-specific release path and integrates with runtime reliability machinery. It does not mean every arbitrary external resource can be represented by a fake integer and considered safely released.
What a strong answer covers
- Finalization can retain an otherwise unreachable object graph until a later collection.
- GC does not automatically call IDisposable.Dispose.
- Resurrection creates a new ownership path and complicates reasoning.
Common pitfall
Assuming the GC invokes Dispose, or treating finalizer completion as immediate memory reclamation.
Follow-up questions
- What new path does resurrection introduce?
- How would a blocked finalizer affect unrelated pending cleanup?
Self-review
Choose what to revisit. These marks are your own assessment and are separate from lesson completion.