• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
The moth suit and wings road is much more exciting than taxes. Or this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic