• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

How can I reduce the perm gen in web-app

 
Greenhorn
Posts: 13
Netbeans IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Saloon Keeper
Posts: 28486
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Netbeans IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Saloon Keeper
Posts: 28486
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
I think I'll just lie down here for a second. And ponder this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic