java.net.SocketException: Cannot allocate memory

Matthew Hall mhall at mhcomputing.net
Fri Jul 5 10:53:21 PDT 2013


I ran into a similar issue before on OS X... there are some bugs Apple introduced into their BSD kernel, where they limited the amount of buffer space you could get for a single socket to a certain percentage of the global mbuf and skbuff pool, in a brain damaged way which causes more problems than it solves. It came up for me when I tried to make a socket with a 16 or 32 MB buffer for some funky high performance networking code. The call to set this buffer size would always fail with a similar error in 10.7 despite working fine in 10.6.

You might check what is happening in the code at the top of the stacktrace and see if you ran into some similar issue. You might also have to read in the XNU kernel code from Darwin to see what errors might get returned inside whatever syscalls Java is using when it happens, dtrussing Java might help with this part also.

Matthew.
-- 
Sent from my mobile device.

Brian Call <brian.call at soterawireless.com> wrote:

>Hi Guys,
>
>I'm seeing an ugly issue crop up on JDK7 for MacOS that I'm at a total
>loss to diagnose or even begin to fix. At random times (and sometimes
>every time) I'm seeing this exception:
>
>Caused by: java.net.SocketException: Cannot allocate memory
>	at sun.nio.ch.Net.joinOrDrop4(Native Method)
>	at sun.nio.ch.Net.join4(Net.java:421)
>	at
>sun.nio.ch.DatagramChannelImpl.innerJoin(DatagramChannelImpl.java:848)
>	at sun.nio.ch.DatagramChannelImpl.join(DatagramChannelImpl.java:866)
>	at
>org.jboss.netty.channel.socket.nio.NioDatagramChannel.joinGroup(NioDatagramChannel.java:158)
>	at
>org.jboss.netty.channel.socket.nio.NioDatagramChannel.joinGroup(NioDatagramChannel.java:135)
>	at
>com.soterawireless.h1s.groups.NioGroupSubscriber.joinGroup(NioGroupSubscriber.java:203)
>	... 5 more
>
>This same codes works great on both Linux and Windows but fails
>intermittently on Mac OS 10.8.x. Google is letting me down and
>stackoverflow isn't being very helpful either...
>
>Does anyone have any insight on what might be causing this join group
>call to fail in such a manner? I could very easily write a simple test
>driver to demonstrate the problem so please let me know if that would
>be helpful. 
>
>Many thanks in advance! 
>
>Blessings,
>
>Brian Call
>brian.call at soterawireless.com
>
>PRIVILEGED AND CONFIDENTIAL COMMUNICATION: This electronic
>transmission, and any documents attached hereto, may contain
>confidential and/or legally privileged information.  The information is
>intended only for use by the recipient named above. If you have
>received this electronic message in error, please notify the sender and
>delete the electronic message. Any disclosure, copying, distribution,
>or use of the contents of information received in error is strictly
>prohibited.




More information about the net-dev mailing list