尝试分配大于 256 MB 的缓冲区时出现 Java 分段错误
我使用的是 64 位 JVM (Oracle),当我尝试分配大于 256 MB 的缓冲区大小时,它会抱怨并抛出“分段错误”错误。我使用 java NIO 分配直接内存缓冲区,并在同一台机器(Linux 64 位)上的 RMI 客户端程序之间传输和接收这些对象。
有什么想法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于内存错误,程序(例如 JVM)中会发生分段错误。要么 JVM 中有一个错误,导致它在启动以使用那么多缓冲区空间时尝试使用计算机上错误的内存部分,要么它尝试分配 256M 内存,但在该过程中它使用的空间比电脑给了它。简而言之,在我看来,64 位 JVM 并不是为了在当前设置下分配那么多空间而构建的。也许您可以尝试配置 JVM,以便它在启动之前向计算机请求更多内存。 jtahlborn 对您询问 JVM 上的最大堆设置是什么的评论也是您在再次运行程序之前应该问的问题。
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.
您是否尝试过错误报告中的以下解决方法?
Have you tried the following workaround from the bug report?