http://deprecated-apache-flink-user-mailing-list-archive.369.s1.nabble.com/heap-dump-shows-StoppableSourceStreamTask-retained-by-java-lang-finalizer-tp15535p15692.html
Hi!
From my understanding, overriding finalize() still has some use cases and is valid if done correctly, (although PhantomReference has more control over the cleanup process). finalize() is still used in JDK classes as well.
Whenever one overrides finalize(), the object cannot be immediately garbage collected because the finalize() method may make it reachable again. It results in the following life cycle:
1) object becomes unreachable, is detected eligible for GC
2) In the GC cycle, object is NOT collected, but finalize() is called
3) If object is still not reachable, it will be collected in the subsequent GC cycle
In essence, objects that override finalize() stay for one more GC cycle. That may be what you are seeing. It should not be a real memory leak, but deferred memory release.
Is this a problem that is affecting the system, or only something that seems odd for now?
If you are very concerned about this, would you be up to contribute a change that uses a PhantomReference and Reference Queue for cleanup instead?
Stephan