javafinalizerobject-destruction

Good uses of the finalize() method


This is mostly out of curiosity.

I was wandering if anyone has encountered any good usage for Object.finalize() except for debugging/logging/profiling purposes ?

If you haven't encountered any what would you say a good usage would be ?


Solution

  • If your Java object uses JNI to instruct native code to allocate native memory, you need to use finalize to make sure it gets freed.