My JVM args are,
set JAVA_OPTS=%JAVA_OPTS% -Xms128m -Xmx800m -XX:MaxPermSize=512m
set JAVA_OPTS=%JAVA_OPTS% -Dorg.jboss.resolver.warning=true
set "JAVA_OPTS=%JAVA_OPTS% -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false"
I tried increasing the -Xmx to 1024 but no use, am getting the same issue,, there server wont even start..
I some sites the suggestion was to reduce the virtual memory size, So decreased the virtual memory size.. initially it was 37000mb then i reduced it to 6000 mb as my ram size is 4gb (i.e virtual memory more that 4096mb),,
- not enough swap space left, or
- kernel parameter MAXDSIZ is very small.
Although it appears that an OutOfMemoryError is thrown this apparent exception is reported by the HotSpot VM code when an allocation from the native heap failed and the native heap may be close to exhaustion.
The message indicates the size (in bytes) of the request that failed and also indicates what the memory is required for. In some cases the reason will be shown but in most cases the reason will be the name of a source module reporting the allocation failure.
If an OutOfMemoryError with this error is thrown it may require using utilities on the operating system to diagnose the issue further. Examples of issues that may not be related to the application are when the operating system is configured with insufficient swap space, or when there is another process on the system that is consuming all memory resources. If neither of these issues is the cause then it is possible that the application is failed due to native leak; for example, application or library code is continuously allocating memory but is not releasing it to the operating system.
For more information: http://java.sun.com/j2se/1.5/pdf/jdk50_ts_guide.pdf
The recommendation for swap space size in the Solaris is that swap should be configured about 30% of physical RAM.
The following link has suggested a workaround to add ‘-XX:+UseDefaultStackSize -Xss256K’ parameter.
This error means that the OS ran out of memory that it could assign to the Java process when the Java process asked for more. Increasing the heap (meaning Java will ask for yet even more memory) is not the way to solve this issue. (It's like you asking me for 10 dollars, I say sorry I don't have 10 dollars, so you say, well how about 20?).
There are several ways to solve this issue. One anandraj hinted at: reduce the stack size (-Xss256k in his example). The other two are:
a) add more memory. Since you are using a virtual machine, increase the VM memory size. But since your host machine has only 4GB, you must add more RAM to the host machine. Trying to run a 6GB VM on a machine with 4GB RAM is lunacy! Especially if 6GB is insufficient memory for the VM to do its job. (I do hope you have a large pagefile, at least 4GB).
b) the other is increase the pagefile size. But that usually costs in performance. more RAM is the only way to go.
Thanks a lot Anand and Peter.. The dollar example from peter was good.
Deployment was successful when i tried the below,
set "JAVA_OPTS=-Xms128M -Xmx512M -XX:MaxPermSize=256M"
As peter pointed out, i have reduced maximum heap size from 800m to 512m. So the operating system has some memory left to do the task..
I had one doubt with -Xss parameter. This parameter should set the size of java stack or and not the size if native method stacks.
So that by setting it to a low value or reducing it will have more memory for native method stack.
But how does this is related to swap space? Am trying to understand what is happening.
Swapping is a process of copying pages from RAM to hard disk, so that the freed space in RAM can be used for other task.
The error is "Out of swap space? ". Out of swap space means that While trying to copy the pages from RAM to Hard disk, there is no space in the Hard disk for swapping the pages.
If so how does setting the -Xss parameter is going to help? Basically reducing the jvm stack size how will it fix the "Out of swap space" issue?
Regarding swap space, think of it this way. Your OS has has a limited amount of memory to work with - the RAM plus the swap space. It will use that as one large chunk of memory. Once you use it all of, it's gone. The only way to increase the amount of memory available is to either add more RAM, or increase the swap space size. I have done both as necessary, though I increased swap space only for a one-time necessity (analyzing a large heap dump), for a production environment I would always increase RAM - having production constantly deal with swapping is a huge performance hit.
When the OS says it is out of swap space that just means it is out of memory, period. OSes will typically allocate any memory that an app asks for in the swap area and then page it into RAM as the app accesses it. Hence the reason why the OS complains about lack of swap space.
Joined: Nov 02, 2009
Thanks Peter, Well explained.
subject: java.lang.OutOfMemoryError: requested 352320 bytes for Chunk::new. Out of swap space?