Github user yaoshengzhe commented on the pull request: https://github.com/apache/spark/pull/126#issuecomment-37492214 @tdas, based on what you said, it's fine to put logic into finalize if we can make sure code in finalize is done in the right way and accept the fact that finalize might never be called. You also mentioned weak reference, I think it is not a bad idea to use some kind of reference classes in java to solve this problem. e.g. java's PhantomReference could guarantee to call cleanup method when it is out of scope.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---