Aug/05
5
Using a Garbage Collector doesn’t free you from thinking
No comments · Posted by Administrator in Java
about references. Memory leaks are still possible - if an object has a "reachable" reference (whatever that is in your context) it won't be garbage collected. You still have to think about who references your objects and how long.
For instance, in my current project using Java Swing, someone said
JAVA:
-
getCurrentFocusManager().addKeyEventDispatcher(this)
in a constructor. Then we got reports OutOfMemory-Error. A simple
JAVA:
-
getCurrentFocusManager().removeKeyEventDispatcher(this);
solved this issue.
It's harder than you think!
