Pradyumna Singh

Greenhorn
+ Follow
since Feb 22, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Pradyumna Singh

Hi,
you can read Head First Design Pattern for object oriented design.

regards
17 years ago
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 ]