java - How can I reduce the memory used for perm gen in web-app -


i use tomcat7. web-app contains:

  • hibernate
  • log4j
  • jdom
  • upload jar
  • mysql driver
  • ...

the total of lib 30 jar files. hoster says: "a lot of memory allocated program(for perm gen , heap). please reduce amount of memory consumed".

how reduce memory requirements of program?

how can reduce perm gen memory?

please me.

you should attach memory profiler first , see type of memory being used , why. the answers question list bunch of profilers try.

heap memory allocate storing objects in java. every time use "new" allocate on heap , memory become garbage collected time after last reference cleared. here typical things might reduce heap usage: switch in-memory parsing api streaming one, perhaps using stax or sax instead of jdom. fix memory leaks or longer-than-necessary object retention cleaning in block object no longer needed. optimize sql queries make them return necessary data app, perhaps adding max row constraint or more restrictive clause. limit size of uploads , stream them temp files on disk instead of keeping them in memory.

perm gen "permanent generation". generally, memory in perm gen never freed until jvm exits. used store loaded classes. can load fewer classes helps here. here ways load fewer classes: try not use multiple versions of same jars. try load jars in widest context possible, preferring tomcat's lib directory or shared lib directory on web-inf/lib. minimize reloading of webapp because every time reload webapp in tomcat, doesn't unload old versions of classes loads new ones.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -