tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shapira, Yoav" <Yoav.Shap...@mpi.com>
Subject RE: Checking Tomcat's Memory
Date Thu, 15 Aug 2002 17:19:08 GMT
Hi,

>CATALINA_OPTS=-server -Xms1g -Xmx3g
>
>and from reading previous e-mails on this list, this should set the JVM
min
>and max heap size, yet how can I verify this?

That's the correct way to set them.  

Here's a simple way to verify things, as I inherently distrust Windows
performance monitoring tools:

- Write a very simple app that would allocate roughly 1 GB of RAM.  For
example, by creating a 1000000 * 1000 array of Integer objects.

Integer[][] hugeArray = new Integer[1000000][1000];
for(l = 0; l < 1000000; l++)
{
  for(l2 = 0; l2 < 1000; l2++)
  {
    hugeArray[l][l2] = new Integer(l2);
  }
}

- Start the server with this app running, but not your other apps.
(Assuming ROOT, examples, tomcat-docs etc take very little runtime
memory).  Make sure you trigger the above code, and see that it runs
without an OutOfMemoryError.  You've just verified the minimum setting.

- Modify the above code to 3000000 * 1000, again run it, verify that it
*does* generate an OutOfMemoryError.  Then you will have verified the
-Xmx setting.

- Obviously, I used perfectly nice round numbers in the above code.  Due
to internal tomcat stuff, other webapps, runtime overhead, JVM overhead,
etc, the actual numbers will be lower.

- You can also verify within the program how much RAM hugeArray took up
by trying something like:

      System.gc();
	long memBefore = Runtime.getRuntime().totalMemory();
      hugeArray = null;
      System.gc();
	long memAfter = Runtime.getRuntime().totalMemory();
      long hugeArrayMemory = memAfter - memBefore;

- As always, stuff like the above should be run several times and
averaged, for a more reliable predictor.  System.gc() is not guaranteed
to run, much less do a full GC, etc etc  I assume you already know all
about that.

Maybe this will help ;)

You can also try MemoryMonitor from these guys:
http://www.spywindows.com/PAGE1/SOFTWARE.HTM

I've used it in the past, it's decent.  But I trust the above approach
more.

Yoav Shapira
Millennium ChemInformatics


>
>I'm currently testing a program that takes a considerable amount of
memory,
>and after getting so many thousand requests (and storing a considerable
>amount of data in memory), the performance becomes horrible (3 to 4
times
>CPU usage, possibly due to gc looking for more memory?).  I suspect the
>memory settings because when the CPU usage starts to spike, the memory
>usage
>tops off and does not appear to go up at all (when it most likely
should
>continue to go up).
>
>Suggestions appreciated!
>
>
>--
>To unsubscribe, e-mail:   <mailto:tomcat-user-
>unsubscribe@jakarta.apache.org>
>For additional commands, e-mail: <mailto:tomcat-user-
>help@jakarta.apache.org>


Mime
View raw message