aspose file tools
The moose likes Tomcat and the fly likes java.lang.OutOfMemoryError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "java.lang.OutOfMemoryError" Watch "java.lang.OutOfMemoryError" New topic


vb krishna

Joined: Jul 01, 2003
Posts: 3
I am on a RH Linux AS 2.1 box,
working with Apache 1.3.27 configured with SSL, tomcat 3.2.4
and jdk 1.4
When I load test the web application we have here with concurrent users working away at it, over a period of time, i get the following errors on the tomcat console.
1. IllegalStateException in huge numbers
2. java.lang.OutOfMemoryError errors
Subsequently, tomcat gets shutdown displaying the following messages.
2003-06-21 19:10:17 - ContextManager: Error reading request, ignored - java.lang.OutOfMemoryError
<<no stack trace available>>
2003-06-21 19:10:17 - PoolTcpEndpoint: Endpoint ServerSocket[addr=,port=0,localport=8080] shutdown due to exception: java.lang.OutOfMemoryError - java.lang.OutOfMemoryError
<<no stack trace available>>
What could be the problem? Could the application be having any memory leaks? Could someone give me any ideas/suggestions?
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12868
What is given as the source of the IllegalStateException ?
Are you using servlets and JSP or what?
JSP can throw IllegalStateException if you use forward when the output buffer has been flushed.
If it was my problem I would write a little servlet to report the current memory usage so you could see if it is using up memory gradually or all in a rush.
vb krishna

Joined: Jul 01, 2003
Posts: 3
Thanks for the response.
Servlets and JSP are being used here.
The exception line goes something like this.
2003-07-01 19:27:29 - Ctx (): IllegalStateException in: R ( /) Current State = FLUSHED, new State = CODING
I tried monitoring the memory usage while the test was in progress. It always shows a minimum of 10% unused at any given point of time and is infact constant at that usage.
There are also lots of java.lang.StackOverflowErrors shown in the console.
Any idea if it is a memory leak problem? Could it be one?
vb krishna

Joined: Jul 01, 2003
Posts: 3
I just monitored the memory resources.
During the 10-minute sequence when a load of 25 users was on the application, the usage was shown as follows.
Swap-out rate, Swap-in rate, Page-out rate and Paging rate was almost towards the 0 on a scale of 100. Page-in rate kept changing, alternating between 0 and 25, an up followed by a down, with an average high time reaching 20. Would this data help?
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
StackOverflow errors? Sounds like one of your servlets is infinitely recursing.

Ron Newman - SCJP 1.2 (100%, 7 August 2002)
Annekee Dufour
Ranch Hand

Joined: Nov 04, 2003
Posts: 41
Actually, it's the illegalstateexception that is recursing.
After the illegalstate exception occurs (meaning you are trying to write something to the outputstream while it is already flushed), Tomcat tries to send an errorpage to the outputstream, which causes another illegal state exception, causing Tomcat again to try and send an errorpage to the outputstream, etc. So you get 1024 illegalstateexceptions and then a stackoverflow error.
I had this problem too (tomcat 3.2.3 jdk1.4.1). I was advised to go back to jdk 1.3 (couldn't do that) or upgrade to jdk1.4.2 (didn't help). In the end I hacked the tomcat code of the handleError method in org.apache.tomcat.core.ContextManager:
if( errorLoop( ctx, req ) || errorServlet==null){
//original code, replaced by ADU according
//errorServlet = ctx.getServletByName("tomcat.exceptionHandler");
//end original code
//start change ADU 5/11/2003
log("Error loop for " + req);
//end change ADU 5/11/2003
That worked.
Don't get me started about those stupid light bulbs.
subject: java.lang.OutOfMemoryError