java.lang.OutOfMemoryException

Hello

I'm posting here becouse I'm now desperate and may be someone here could help

I'm experiencing a problem with my app, it's running un Tomcat 4.1 with java 1.4.2_12 and I'm getting java.lang.OutOfMemoryError when it tries to process something in the range of 5000+ registers.

I've tries setting CATALINA_OPTS and also writing catalina.bat itself with configurations, setting Xms256m, Xmx512m, and XX:PermSize, XX:MaxPermSize and XX:MaxDirectMemory with values from 256 to 512m and still have no results.

Does anyone know any other ideas i could try or how could I find out what type of memory is my app running out of? On the server, tomcat4.exe proccess doesn't seem to be using more than 130M at any time.

Thanks.

[764 byte] By [Metallana] at [2007-11-27 11:17:53]
# 1

Rather than CATALINA_OPTS, define JAVA_OPTS with -Xmx512m as an enviornment variable (in the same location you defined JAVA_HOME). This gives more memory to the JVM.

If instead you are running tomcat within Eclipse, go to something like <window><preferences><tomcat> and find where it has the jvm settings, add -Xmx512m to it. This is because when running tomcat within Eclipse, it uses parameters for the jvm defined in Eclpise, not in your computer system variable.

On a bigger note, I think its more likely you have a bug in your program than the JVM running out of memory. Something like an infinite loop. You can single step through your code, or pepper it with System.out.println() statements.

George123a at 2007-7-29 14:27:32 > top of Java-index,Java Essentials,Java Programming...
# 2

Are you able to run ur program and than u exp OutOfMemory or it is at the startup. The reason why i am asking this is because of ur app runs fine for some time and than gives this error than there might be two reasons .. one might be u are not releasing an object and that obj instances are clogging up memory with every new instance and causing an OOM exception .... Second reason could be that the garbage collection is not working as intended. Try upgrading the jre to 1.5 there are lot of good gc techniques you can implement . See through the release notes for 1.5 ...

Rohan.Desaia at 2007-7-29 14:27:32 > top of Java-index,Java Essentials,Java Programming...
# 3

Thanks for the answers

I know there is no infinite loop or something, and actually the program behaves "normally" with certain quantity of transactions, let's say up to 2000

When I put it a little higher, around 5000, it starts running out of memory.

I'll try the Java_OPTS thing and hopefulyl it will work.

It makes sense what you mentiones, since when i run it with the WebSphere (Eclipse based) and not Tomcat it does not fail, that's why I think there must be something with the config.

Metallana at 2007-7-29 14:27:32 > top of Java-index,Java Essentials,Java Programming...
# 4

I made a discovery!

Turn out that I found something that can help me, but I don't know how to fix it

I stopped the Tomcat Server from the Services window, and then, instead of re-starting it, I used the startup.bat included in the bin directory of the Tomcat4 installation Folder, and everything worked just fine!

Then i stopped it, and opened the Service again (it executes tomcat4.exe) and it failed again (as expected at this time)

Anyone know something about this? Why the service doesn't do the same that the bat File? Souldn't it?

I feel like I'm getting close to fixing my problem, I'll go check some Tomcat 4 Documentation

Any healp would be greatly appreciated, and again, thanks to those who answered already, becouse your answers made me look at that.

Metallana at 2007-7-29 14:27:32 > top of Java-index,Java Essentials,Java Programming...