Throw the following code into a jsp and view it.  It'll give you a little
graph showing you how much memory Tomcat can use, has allocated and is
using.  This will tell you if you've properly set the max memory value and
may help you figure out what's happening.  Best,  Joe

StringBuffer mb = new StringBuffer();
mb.append("<font face=arial size=-1>");

mb.append("<br><br>");

Runtime rt = Runtime.getRuntime();
mb.append("Maximum memory available: " + rt.maxMemory() + "<br>");
mb.append("Total memory allocated: " + rt.totalMemory() + "<br>");
mb.append("Free memory unused: " + rt.freeMemory() + "<br>");

double used = 0;
double free = 0;
double available = 0;

used = rt.totalMemory()-rt.freeMemory();
free = rt.freeMemory();
available =  rt.maxMemory()-rt.totalMemory();

double usedpercent = (used/rt.maxMemory()) * 100;
double freepercent = (free/rt.maxMemory()) * 100;
double availablepercent = (available/rt.maxMemory()) * 100;

mb.append("<br><br>");

mb.append("<table cellpadding=0 cellspacing=1 border=4 width=100% >");
mb.append("<tr>");
mb.append("<td bgcolor=#ff0000 width="+(int)usedpercent+"% align=center>");
mb.append("<font face=arial size=-2 color=#ffffff>");
mb.append("U");
mb.append("</font>");
mb.append("</td>");
mb.append("<td bgcolor=#00ff00 width="+(int)freepercent+"% align=center>");
mb.append("<font face=arial size=-2 color=#ffffff>");
mb.append("F");
mb.append("</font>");
mb.append("</td>");
mb.append("<td bgcolor=#cccccc width="+(int)availablepercent+"%
align=center>");
mb.append("<font face=arial size=-2 color=#ffffff>");
mb.append("A");
mb.append("</font>");
mb.append("</td>");
mb.append("</tr>");
mb.append("</table>");

mb.append("<br><br>");

mb.append((int)used + " <b>U</b>sed - "+(int)usedpercent+"%<br>");
mb.append((int)free + " <b>F</b>ree - "+(int)freepercent+"%<br>");
mb.append((int)available + " <b>A</b>vailable -
"+(int)availablepercent+"%<br>");

out.print(mb.toString());



-----Original Message-----
From: Oleg [mailto:[EMAIL PROTECTED] 
Sent: Saturday, February 19, 2005 4:09 AM
To: Tomcat Users List
Subject: out of memory when there is plenty

Windows 2003
Tomcat 5.0.28

Ok I searched and searched endless and still cannot  understand what the
problem in my case. Ok, I understand that there can be a leak in teh code
and thats why Tomcat runs out of memory. However, the server got total 2GB
Ram memory, Tomcat is set to use min 512, max 1024. When I start getting an
out of memory error, Tomcat5 in task manager shows anywhere 350MB to 390MB,
I run a script on the server to check Runtime and it shows that memeory
usage is very low compared to max/min settings and there are about 600MB
available.

My question is what can cause Tomcat to report out of memory error when so
much is still available.

Thank you
Oleg

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to