Well, consider the reason why WHY finalize and Co are problematic: as you know, there is no guarantee that finalization will be called before the VM is closed, which means that a special cleanup code will not necessarily be launched (imo a bad solution, I I donβt see any problems to start the finalization queue when cleaning, but itβs good that it is). Also this is exactly the same situation in C #
Now your objects only consume memory, which will be cleaned up by the OS anyway when the VM is destroyed, so the only case where finalization is problematic will not matter to you. So yes, you can really use this option, and it will work fine, but it cannot be considered a great architectural project - and as soon as you add resources to your C ++ code, where the OS will not correctly handle cleaning, you will encounter with problems
Also note that the implementation of the finalizer leads to some additional overhead for the GC and means that cleaning up one of these objects requires two cycles (and whatever you do, never save the object in the finalize method)
source share