aspose file tools*
The moose likes JBoss/WildFly and the fly likes java.lang.OutOfMemoryError: requested 352320 bytes for Chunk::new. Out of swap space? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "java.lang.OutOfMemoryError: requested 352320 bytes for Chunk::new. Out of swap space?" Watch "java.lang.OutOfMemoryError: requested 352320 bytes for Chunk::new. Out of swap space?" New topic
Author

java.lang.OutOfMemoryError: requested 352320 bytes for Chunk::new. Out of swap space?

srini arumugam
Greenhorn

Joined: Nov 02, 2009
Posts: 14
Hi,, Am getting the below issue when i deploy my code in "jboss-5.1.0.GA",,
An unexpected error has been detected by Java Runtime Environment:


java.lang.OutOfMemoryError: requested 352320 bytes for Chunk::new. Out of swap space?

Internal Error (allocation.cpp:218), pid=5076, tid=4692
Error: Chunk::new

Java VM: Java HotSpot(TM) Server VM (11.0-b11 mixed mode windows-x86)
An error report file with more information is saved as:
D:\jboss-5.1.0.GA\bin\hs_err_pid5076.log

If you would like to submit a bug report, please visit:
http://java.sun.com/webapps/bugreport/crash.jsp
The crash happened outside the Java Virtual Machine in native code.
See problematic frame for where to report the bug.


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),,
Suggestions please...
anandraj tadkal
Ranch Hand

Joined: Feb 22, 2011
Posts: 98

Possible causes:
- not enough swap space left, or
- kernel parameter MAXDSIZ is very small.

Solution:
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.

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4916142

Add: -XX:CodeCacheMinimumFreeSpace=2M -XX:+ReservedCodeCacheSize=64M -XX:PermSize=128m -XX:MaxPermSize=384m (As per your other JVM settings)

http://weblogic-wonders.com/weblogic/2010/12/30/different-out-of-memory-issues/

Hope it helps you debug further.


Regards,
Anandraj
http://weblogic-wonders.com
Follow us on facebook:
https://www.facebook.com/weblogicwonders
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5845
    
    7

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.


JBoss In Action
srini arumugam
Greenhorn

Joined: Nov 02, 2009
Posts: 14
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.

From the link,
http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html
am not able to clearly figure out the default value of UseDefaultStackSize. Am using java 1.6, So if the default stack space 512k then reducing it to 256k will free some space so that the operating system can use it.

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?


Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5845
    
    7

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.
srini arumugam
Greenhorn

Joined: Nov 02, 2009
Posts: 14
Thanks Peter, Well explained.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.lang.OutOfMemoryError: requested 352320 bytes for Chunk::new. Out of swap space?