wood burning stoves 2.0*
The moose likes Java in General and the fly likes Things to keep in mind while programming to avoid heap and permgen errors? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Things to keep in mind while programming to avoid heap and permgen errors? " Watch "Things to keep in mind while programming to avoid heap and permgen errors? " New topic
Author

Things to keep in mind while programming to avoid heap and permgen errors?

scott miles
Ranch Hand

Joined: Jun 16, 2011
Posts: 70
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.

3)Too many string literals used in application.

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?


posted at https://forums.oracle.com/forums/thread.jspa?threadID=2281919&tstart=0 too but did not get comprehensive reply?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Things to keep in mind while programming to avoid heap and permgen errors?
 
Similar Threads
garbage collection heap?
BEA 10 Admin server out of memory issue
How to read memory usage for process running in Linux,
Issues with welcome file list in jsf
Instantiates Logger as STATIC