Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tomcat out of memory with some JREs

 
mikael eriksson
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a peculiar memory problem with Tomcat under certain JREs and JDKs.

I run winxp sp2, tomcat 5.5.12 as a service and mysql 5.0.18.
I have set the tomcat and java environment variables.

On one machine using jre 1.5.0_08 results in out of memory very quickly running the webapps. Switching to jdk 1.5.0_08 does not help. On another machine the same settings results in proper behaviour.

I think there is some problem with how JVM sets memory to Tomcat. The screw-up came when I was playing with these min/max memory settings. However when I set it back as it was, the screw-up is still there.

I can't find the tomcat5w.exe settings somewhere in the registry. Can I check somewhere which settings really is set for Tomcat?
 
Bart Saelen
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a simular problem

when running tomcat 4.1.24 as a service with JDK 1.4.2 i get out of memory regulary. I also changed the memory settings.

It happens only on the production server (win 2003) and not on the testmachine (also win 2003)

Do you really think there is a problem with Tomcat setting JVM memory?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the problem is a memory leak in your app then allocating more heap space will only postpone the out of memory crash.
If it isn't and your app just needs more memory than the 64k default, the raising it will fix the problem.
 
Simon Joseph Aquilina
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How could there be a memory leak in Java? I had the same problem, I increased the size of the heap. So far it seems to be working. However I do not know how could there be a leak in Java, since the GC should run and remove all objects that have no reference. And there should be a lot of objects wothout a reference after the request.

I am definitly sure I am saying something stupid (sorry). But isn't what i said true?

regards,
Sim085
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nope, not saying anything stupid.

It is possible to create memory leaks in Java (though you have to work a little harder at it).

The most common case in a database driven webapp is caused by failing to return database connections to the connection pool.
Every hit that needs a connection will pull one from the pool. If it doesn't return it when it's done, then the pool will keep growing.
GC will never be able to collect the connection objects because there are still references to them in the pool.
[ September 02, 2006: Message edited by: Ben Souther ]
 
Simon Joseph Aquilina
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ben,

I understand what you say. I will keep that in mind

Thanks and Regards,
Sim085
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic