Explicitly tagging an object as unused
843853Jul 9 2004 — edited Jul 11 2004Just read an article on gc tuning (http://www-106.ibm.com/developerworks/java/library/j-perf06304/?ca=dgr-lnxw07BlogFix)
where memory leaks are caused by the so called "unintentionally retained objects".
Currently, detecting memory leak in Java is done using memory profiler to monitor
memory usage and select which objects are suspected to cause of memory leaks.
Then, the programmer must decide/guess which of the suspected objects really cause
memory leaks.
Is it worthed to provide an API that explicitly tags an object as unused, so that memory
profilers can find which objects are 100% the cause of memory leak? The notion of this
API is similar to free in C, however, this API does not affect the decision made by gc
regarding the reclaimability of an object, nor does it force gc to reclaimed the object.
Object marked by this API means "I'm no longer needed by the user/program/algorithm.
Hence, I should be able to be reclaimed by gc. If gc deemed I'm still referenced, this
means the programmers make mistakes, and thus, they must fix the program".