my understanding is that Jboss start with the minimum memory configured to 128MB and keeps getting more as needed, but when the allocated memory is not used anymore (becomes Free memory), Jboss should return this memory to the OS
No, that is not correct. The JVM, once it asks the OS for memory, will never release that memory back to the OS. If you do not want the JVM to consume 1.5GB of memory, do not set -Xmx that high.
I was wrong. I just talked to my JVM expert and the JVM will give memory back to the OS under certain circumstances. It will give back memory only during a garbage collection. Taking a snapshot of memory usage is not sufficient to make any conclusion about memory. If the JVM is not doing anything it will not just suddenly wake up and say "oh, I have too much memory, I think I will give some back." You need to gather garbage collection data while running the JVM and that data will indicate when, or if, the JVM is giving memory back to the OS.
Note that JBossAS has no say whatsoever in this matter.
thanks for the reply..
I agree with u, the JVM should return memory to OS after GC... but this is not happening in my case because I can see the total memory never decrease (while monitoring for 3-5 days)... so there is no memory returned to OS, which conflict with our theory....
I have also monitored the jboss process memory-utilization on the unix machine it gave the same figure as the Jboss admin console... that is my jboss process keeps eating memory without returning it back to OS till it reaches the max assigned memory then it give the OOME....
I am wondering is this a known issue in 4.0.5 (I have another server 4.2.1 running in the same machine, itis not doing that).... if not, then what to do to get red of this... i tried every thing with no result...
You mention monitoring JVM memory usage. How are you doing that, using system tools? Unfortunately, that is not very helpful. You really need to monitory garbage collection data (e.g., -verbose:gc and similar JVM options) and examine that. That is the only thing that will tell you what is really going on.
Be aware that there will often be unused heap memory - the JVM will rarely use all of the memory that it asks for. For example, with a 1GB heap and a 200MB you generation, you will typically have at least 200MB of unused heap memory (unless you have a memory leak). The unused memory is a side0effect of the algorithm the JVM uses to determine when to do a full garbage collection.
See my presentation at http://www.cecmg.de/doc/tagung_2007/agenda07/24-mai/2b3-peter-johnson/index.html
I have monitored the memory using system tools, jboss web console and jprofiler... all gave the same result..
following is snapshot of jboss web-console main screen showing the resouce utilization
Free Memory: 981 MB
Max Memory: 1333 MB
Total Memory: 1058 MB
JVM Version: 1.5.0_07-b03 (Sun Microsystems Inc.)
JVM Name: Java HotSpot(TM) Server VM
In the run.cfg I configured the startup memory to 128m and the max to 1.5g... jboss start with 128m and kept eating more memory (although that there were always free memory avaialble --- monitoring the free memory figure of the web-console)..... till it reached this state of consuming 1058mb... my understanding Jboss/JVM should not ask the OS for more memory if there is free memory available (cleaned by garbage collector)... with time the total memory reaches the max memory and the jboss starts throwing OOME.
so the question again, what can I do to make the JVM/JBoss uses the free memory instead of consuming new memory from the OS.
I repeat : none of those tools really tell you what is going on with garbage collection. They only give snapshots of current memory usage. You need to use -verbose:gc or -XX:PrintHeapAtGC, or a similar option to find out what is really going on.
The JVM will eat up memory if it thinks it needs more - this has more to do with the amount of objects that survive the gc than with how much free space is available after the gc. If you want to limit its memory consumption, set the max heap to a reasonable amount. I always recommend setting min and max heap to the same size. But only after analyzing -verbose:gc data to determine the optimal heap size.
Is the OOME due to the heap or the perm gen? What is the exact error message?