java.lang.OutOfMemory

  • Thread starter Michael Borgwardt
  • Start date
M

Michael Borgwardt

michael said:
Hi I'm getting the java.lang.OutOfMemory error in my webapp using tomcat 5.

How to debug and find out the cause?

You need a so-called "profiler". Or maybe just a bigger maximal heap size
(-mx option to the JRE, probably configurable somewhere with Tomcat).
 
F

Fedor

Michael Borgwardt said:
You need a so-called "profiler". Or maybe just a bigger maximal heap size
(-mx option to the JRE, probably configurable somewhere with Tomcat).
No! You need to decrease the heap size to crash te application in an
earlier stage, so you'll find your bug earlier.


F.
 
M

Michael Borgwardt

Fedor said:
No! You need to decrease the heap size to crash te application in an
earlier stage, so you'll find your bug earlier.

Nonsense. You just make it more likely that a perfectly legitimate
space allocation instead of the memory leak (if there is any) will
cause the OutOfMemoryError. At best, it may alarm you to points
where your code is not wrong but could be more economical.
 
M

Murray

michael said:
Hi I'm getting the java.lang.OutOfMemory error in my webapp using tomcat 5.

How to debug and find out the cause?
Any step by step guide?

Does this by any chance happen after you've been making changes to code and
Tomcat has automatically reloaded the context several times? If so, this is
common, I think it's a bug in javac? Maybe not, but I see it regularly if
I'm modifying a lot of code ...
 
M

michael

Hi I'm getting the java.lang.OutOfMemory error in my webapp using tomcat 5.

How to debug and find out the cause?
Any step by step guide?
 
B

Boudewijn Dijkstra

michael said:
Hi I'm getting the java.lang.OutOfMemory error in my webapp using tomcat 5.

How to debug and find out the cause?
Any step by step guide?

If you can point out some suspicious code fragments, you can catch the error
by placing a try/catch block around it.
 
C

Chris Smith

Boudewijn said:
If you can point out some suspicious code fragments, you can catch the error
by placing a try/catch block around it.

Possibly, but keep in mind that if code is leaking memory, any
allocation can fail. The fault is not isolated to the section of code
that causes the problem. Hence, a profiler is really a much better
investment of time in most cases.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
B

Boudewijn Dijkstra

Chris Smith said:
Possibly, but keep in mind that if code is leaking memory, any
allocation can fail.

If code is leaking memory, then there won't be any suspicious fragments.
I myself have never encountered leaky code in my few years of Java
experience. I advised to point out suspicious fragments, because my only
experiences with OutOfMemoryErrors were caused by infinite loops and
recursions.
The fault is not isolated to the section of code
that causes the problem. Hence, a profiler is really a much better
investment of time in most cases.

"Most cases" here applies to a particular segment of Java code under
development.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top