1 Reply Latest reply on May 20, 2008 10:18 PM by Peter Johnson

    Maximum JVM Settings?

    Ed Schneider Newbie

      I am running a Windows box with 4GB of RAM and JDK 1.6. I have nothing else running on the server. What is the maximum memory I can allocate to JBoss 4.0.1?

      I currenlty startup JBoss with \bin\run.bat: set JAVA_OPTS=%JAVA_OPTS% -Xms512m -Xmx1536m.

      If I increase the -Xmx greater than 1536m, I get the following error on startup:

      Error occurred during initialization of VM
      Could not reserve enough space for object h
      Could not create the Java virtual machine.
      Press any key to continue . . .


        • 1. Re: Maximum JVM Settings?
          Peter Johnson Master

          Hmm, I thought I had answered this earlier. Perhaps I posted my reply to the wrong post. Bet they are confused...

          Anyway, the largest possible heap size depends on the largest chunk of consecutive memory that the JVM can allocate (not all JVM need consecutive memory, but Sun's does). If you are running a 32-bit JVM on a 32-bit OS, then you need to understand how memory is laid out. Each app has only 4GB of addressable space. Typically, the OS uses 2GB and lets the app have the other 2GB. The app's address space it used up by usually by the exe in low memory and the OS DLLs in high memory just under the 2GB border (even the JVM DLLs load up into high memory). This leaves about a 1.5GB contiguous area in memory where the JVM can allocate the heap. The actual size grows and shrinks depending on the OS version and patches.

          There is a /3GB os boot option you can use to split the app's memory such that the OS uses only 1GB and the app gets 3GB. Unfortunately, the OS DLLs (and JVM DLLs) still occupy the area just under 2GB, so you still end up with only 1.5GB of contiguous space. If you use a JVM that does not need contiguous memory to allocate the heap you can get about 2.7GB heaps. Of course, the /3GB options does have its down sides. Having only 1GB for its memory structures (threads, file handles, object handles, etc) can cause the OS to run out of resources. Usually you see this when the JVM is unable to create another thread. And app server create lots of threads.