2 ms·
I would put code in them that cleans up things that the OS would clean up anyway when the program terminates. Things such as unmanaged file handles and unmanage
by mattchamb 11y ago
I would put code in them that cleans up things that the OS would clean up anyway when the program terminates. Things such as unmanaged file handles and unmanaged memory handles.
By cleaning up these things in the finalizer, they get deallocated during a long running process when the process encounters memory pressure and runs the GC, or they get cleaned up automatically when the program terminates.