This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I some time get Java heap error and permgen error in my project which is having large code base i.e 2500 java lasses.
I know about two jvm parameter which we can set to deal with for java heap we can -Xms 1024 -Xmx 1024 and for permgen we can set -Xmx:permgen 256m.
That also sometime does not solve the problem. I am looking forward if we can do something proactively while programming the application so that we can descrease the probablity of facing such issues. here is my understanding
Permgen error can occur either at serverstart up or at application run time. I can think two main reason for this:
1) More the classes will be loaded more spaces will be eaten in permgen area.
2) Too many reference of static variable in application (as they gets also stored in permgen area). Agreed it wont make much difference. Probably millions of variable can make difference.
So while programming we can take care of points 2 and 3 if we can avoid them. Looking for some other solutions also which we can keep in mind while programming to avoid these situations(For both permgen and java heap out of memory issue). Could not come up if we can follow any proactive approach for not facing java heap out of memory issue?