• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

How can I reduce the perm gen in web-app  RSS feed

 
Greenhorn
Posts: 13
Firefox Browser Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I use tomcat7. My web-app contains:

hibernate
log4j
jdom
upload jar
mysql driver
...

the total of lib is 30 jar files. My hoster says: "A lot of memory is allocated to the your program(for Perm gen and heap). Please reduce the amount of memory consumed".

How do I reduce the memory requirements of my program?

How can the reduce the perm gen memory?

please help me.
 
Bartender
Posts: 19801
93
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Amir!

Unfortunately, I think that Hibernate is what's eating a lot of your PermGen space. I have found the combination of JSF+Hibernate to be especially hungry.

Fortunately, my ISP allows me to configure my Tomcat server any way I want, so I bumped up a few parameters. From what I've seen, there's a fixed overhead that's fairly close to the Tomcat default PermGen size, and so I don't have to add much.

It would cost me a lot more to have to re-architect my webapps to not use ORM - to say nothing of the maintenance cost issues. Lower cost of maintenance is, after all, one of the primary reasons for using an ORM to begin with. That and tunability. So I just grit my teeth and trust that the Hibernate people will tune it to be PermGen-friendly as time goes by.
 
amir kawaja
Greenhorn
Posts: 13
Firefox Browser Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks tim .
i used java VisualVM profiler.
in local host has changed heap size(10mb to 29mb) and perm gen (10mb to 20mb) and classes (2000 to 4500) .

This amounts to a project is too ?!.

You mean that I do not use hibernate ? use jdbc commands ?
There is no way ?


 
Tim Holloway
Bartender
Posts: 19801
93
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm sure that there is a way. In fact, finding ways like that are my speciality, so in theory I should have all sorts of money in the bank.

However, these days, 6GB of RAM is selling at retail price for about $45US. Even in the cheapest sweatshop in India, that's probably less than a day's pay for a programmer and it would take far more than a day to rewrite any sizable webapp to use JDBC. And, as I said before, the ongoing cost of tuning and maintaining JDBC code is a lot higher that the equivalent JPA (Hibnernate) code costs.

There is no "free" solution. But in most cases, given a choice between paying an expert like me, rewriting the ORM layer of the app or just plugging in a new pair of memory sticks, the option isn't even a question. The memory sticks are a lot cheaper.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!