Hi,
i ran the program, the error is heap overflow.
case 1: When there is no print statement in finalize
the objects are being created but garbage collector runs at apropriate times and frees the memory in the heap, so there is no problem.
case 2: When something is being printed in finalize
objects are being created at the same rate but they are not being released at the same rate as in first case. This is because before being released, something is being printed at the console which is much much slower as compared to other operations beng performed in the program. so the garbage collector is not able to free the memory at the same rate as last case. so there is heap overflow in this case.
One solution to this is to increase the maximum heap size of the java virtual machine.
But i think, if in the finalize, you are just releasing some memory and not doing any input/output operations, then you will never face the problem.
thanks
[ February 22, 2007: Message edited by: chilled blue ]