0

I hosted my web application in windows server.It suffered outofmemoryerror in three days once.Then i restart the tomcat it works fine for next three days and again suffered after three days.I googled for solve this problem,some bodies say to increase the perm-gen space.That only postpones that error to six days.Now six days once my web app generates out of memory error.I also performed code optimization too.For examples

`String s="example";` 

It's string literal.Garbage collector does not take literals.so i changed literals to object in all places and reduce some unnecessary code also.But now also i sufferd from the same.
How to prevent permanently from outofmemoryerror?

Any Help Will Be Greatly Appreciated!!

Selva
  • 1,620
  • 3
  • 33
  • 63
  • possible duplicate of [Dealing with "java.lang.OutOfMemoryError: PermGen space" error](http://stackoverflow.com/questions/88235/dealing-with-java-lang-outofmemoryerror-permgen-space-error) – Roman C Sep 13 '14 at 10:53
  • 1
    You "changed literals to object in all places"? What does that even mean? – Dave Newton Sep 13 '14 at 16:39
  • garbage collector does not take literals.but take objects. – Selva Sep 15 '14 at 03:38

1 Answers1

0

Obviously you have some memory leakage in your application. Look for any object being created repeatedly like Statement or PreparedStatement object and not being closed.(I have had this issue).Or you can check if any object being created in any servlet that is not being disposed of.
Do provide the stack trace with the file which contains the code that caused this exception for further specific help.