Henry Wong wrote:
A copy collector splits the heap in half and move objects between the two halves during the GC cycle. And yes, "it will cost a lot".
The theory behind using a copy collector for the new generation objects, is that most objects do not last very long.
We divide objects into young generation and tenured generation. Question is, how to divide ? Yes, the object defined inside a method definitely is short lived, should be in young generation. My coding above is not this case, so local object is not our topic here.
Objects defined in the instance level, how to divide them into young generation and tenured generation ?
This topic has been spun off from here... http://www.coderanch.com/t/520071/java/java/detect-memory-leak
Now, if you want to know how the GC is configured, then you should google for a java GC tuning guide.