6 Replies Latest reply on Apr 28, 2009 12:54 AM by Antonello none

    Physical vs Virtual Memory

    Antonello none Newbie

      Good morning,
      i'm configuring JBoss 4.0.2 on Windows Server 2003 and i have a lot of problem concerning the memory managment. On this server are configured 10 VM for JBoss instances with this configuration:

      -Xmn1024m -Xms1024m -Xmx1100m -XX:PermSize=512m -XX:MaxPermSize=512m -XX:+UseParallelGC

      The server seem to allocate VM reserved XMX memory (1024MB*10) in the virtual memory instead on the physical memory. Only the MaxPermSize space (512*10) seem to be loaded in RAM, indeed, the related JBoss process use only 512MB of system physical memory. This results in an high swap file utilization, very low physical memory usage and in frequent OOME error. The paging usage peak is at 100% and the memory usage is always on 60% of 16GB avalaible.
      I'm googling without find anything regarding. What's wrong?
      Thanks in advance

        • 1. Re: Physical vs Virtual Memory
          Antonello none Newbie

          the posted configuration is wrong, this is the actual configuration:

          -Xmn256m -Xms1024m -Xmx1024m -XX:PermSize=512m -XX:MaxPermSize=512m -XX:+UseParallelGC

          • 2. Re: Physical vs Virtual Memory
            Peter Johnson Master

            I think this has to do with how Windows allocates memory. When the JVM first comes up it will as for the 1GB or memory for the heap but it will not immediately make use of that memory. Usually what happens is the OS marks that 1GB of memory as "committed" but physically allocates only a fraction of that to the JVM. As the heap fills up, the OS will allocate more memory to the JVM (that is, swap in memory from the swap file). Of course, the JVM will never really use the full 1GB (probably at most round 3/4GB).

            One thing you could try is to allocate, say, 2GB of RAM to a virtual machine and do not allocate any paging file within the OS. That should for at least the Windows running in the VM to not play with the pagefile. If the host OS is also Windows, you can try the same trick there. (That should work - I ran my desktop for a while without any pagefile, didn't even notice it until I tried to run too many VMs are ran out of memory.)

            • 3. Re: Physical vs Virtual Memory
              Antonello none Newbie

              First of all, thanks for you answer.
              You are right, I also think that's a problem of memory allocation in Windows Server. I just tried to set the page file size to 0, but JV refuse to start.
              Is very strange:
              when the OOME errors occurs and the overloaded JavaService process hangs, the paging file usage peak is 100%, but the "peak mem usage" value of task manager is always 512MB for all JavaService processes! It seems that windows does not use more thank 512MB (the exact value of maxpermsize), nerver! I'm a bit frustrated, i read all 73 pages of this forum and searched all the web without find any answer.

              • 4. Re: Physical vs Virtual Memory
                Peter Johnson Master

                It will use more than that. I have just been running some perf tests with a 1GB heap and my JVMs memory usage was over 1GB. But that was not on a VM. Hmm, I have a Server 2008 VM, perhaps I'll fire it up and run my code there - I'll let you know my results.

                I see the term "JavaService". Are you certain that you changed the JVM parameters properly? JavaService (if it is http://wrapper.tanukisoftware.org/) uses registry entries to specify the heap size. Also, it has been a while since I used JavaService and I cannot remember if it forks a separate Java process or if it loads the JVM DLL directly. A tool such as Process Explorer from sysinternals should shed light on that.

                Also, if you set the pagefile to 0, make sure you allocate enough memory to the virtual machine. Without the JVM running you should have at least 1.5GB free memory. You might have to allocate 2.5GB or 3GB to the virtual machine.

                • 5. Re: Physical vs Virtual Memory
                  Peter Johnson Master

                  I ran my test on my VM with Windows Server 2008. According to Task Manager, the working set was only 500MB, though the committed memory was 1.7GB. Looks like Windows has a hard time reporting correct memory usage while running as a VM (though this is not a surprise - OSes running within a VM seldom report correct performance statistics). I also had verbose:gc set, and here is an example GC that shows a lot of heap usage:

                  680.862: [GC 929878K->893472K(1044992K), 0.0488677 secs]

                  • 6. Re: Physical vs Virtual Memory
                    Antonello none Newbie

                    Yes, you are right, Sysinternal ProceXp displays the real working set that reaches 900MB
                    Thank you !