CS202 Java-73
finalize() is not a destructor!
lBut! This is not a destructor.
lJava objects do not always get garbage collected –
lThe garbage collector is only run after all references to an object have been released and memory is insufficient (or running low). It may just automatically return the memory to the operator system after execution!
•So, use finalize() for releasing memory that the garbage collector cannot predict, but you may need to explicitly cause the garbage collector to be exeucted: System.gc()
lBottom line, finalize() cannot be relied upon.
lEven functions that look like they should cause finalize to be used are problematic and at times buggy. Its invokation is not guaranteed!
•