PTC interview question

How memory leak can be avoided in Java.