13

I am using a 64-bit JVM (Oracle), when i try to allocate buffer sizes larger than 256 MB it complains and throws a "segmentation fault" error. I and allocation direct memory buffers using java NIO, and transferring and receiving these objects to and from a RMI client program on same machine (Linux 64 bit).

Any idea?

Raedwald
  • 46,613
  • 43
  • 151
  • 237
suleman
  • 147
  • 1
  • 1
  • 3
  • 10
    Can you post a bit of code? – Paul W May 27 '11 at 11:17
  • 1
    what is your max heap setting? – jtahlborn May 27 '11 at 11:37
  • 5
    A segmentation fault can only occur if you have a bug in a JNI library or in the JVM. The first thing I would try is ensure you have Java 6 update 25 or the latest version. – Peter Lawrey May 27 '11 at 11:44
  • I am using JDK 1.6 update 25, (64-bit) JVM, and maximum heap size is set to 8000MB, while DireactMemorySize (-XX:MaxDirectMemorySize=3000M ) is set to 3000MB. I am using jog-amp JOCL (Java-OpenCL binding to create the required size buffers using my Distributed (based on RMI) framework – suleman May 27 '11 at 13:50
  • Is there some limitation (maximum size of object) that can be sent using serialization may be object greater than size of 256 MB causing the problem? ANY idea? – suleman May 27 '11 at 14:04
  • JVM produce a log when it crash. Could you post it? – Plínio Pantaleão May 27 '11 at 18:52
  • I would guess (without knowing anything about that particular JVM) that whatever memory mapping scheme is used inside the JVM imposes a 256mb limit on the size of a single contiguous allocation. – Hot Licks May 28 '11 at 00:50
  • If you are using the OpenJDK build, then try the Sun Java build. Otherwise it sounds like something that should be taken to the HotSpot mailing list. – Chris Vest Jun 03 '11 at 20:53
  • @suleman, did you manage to get crash dump or you see the seg fault only in syslog? If you don't have the crash dump, most likely it's a stackoverflow, or just low stack. Try to increase the max stack, if you have deep graph traversals. Also the max heap setting has nothing to do w/ the direct memory. – bestsss Jun 03 '11 at 21:57
  • 1
    This could be related to a bug report I filed: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7027845 – Gili Jun 11 '11 at 16:22
  • You can't transfer direct byte buffers via RMI. They are not serializable. Unclear what you're asking. – user207421 Mar 11 '17 at 09:41

2 Answers2

4

Segmentation Faults happen in programs (such as the JVM) due to memory errors. Either the JVM has a bug in it that makes it try to use the wrong section of memory on the computer when its cranked up to use that much buffer space, or it tries to allocate 256M of memory and in the process it uses more space than the computer gave it. In short, it sounds to me like the 64 bit JVM wasn't built to allocate that much space with its current settings. Perhaps you could try to configure the JVM so that it asks for more memory from the computer before it starts up. jtahlborn's comment on your asking what the max heap setting is on the JVM is also a question you should ask before you run the program again.

djhaskin987
  • 9,741
  • 4
  • 50
  • 86
-3

Have you tried the following workaround from the bug report?

Run System.gc() before ByteBuffer.allocateDirect()...

Zian Choy
  • 2,846
  • 6
  • 33
  • 64
  • 1
    Completely irrelevant. Direct buffers don't come out of garbage-collectable space. – user207421 Jul 11 '11 at 04:36
  • @EJP: if you read the bug report, it gives a plausible justification as to why that might help the matter. – Steven Schlansker Jul 19 '11 at 19:00
  • 1
    You can never be sure, that System.gc() does anything... so that's not a good way to solve any problem... i agree to EJP and i would extend his Statement to that this call is in the majority of cases completely irrelevant. It's just a HINT to the JVM that the program would like to make a GC but you can never say if the JVM will. – Chris Aug 04 '11 at 07:28
  • 1
    @Chris This is a segmentation fault, not an out of memory error. Your answer makes no more sense six years later than it did at the time. – user207421 Mar 11 '17 at 09:42