【发布时间】:2014-07-24 11:34:50
【问题描述】:
我正在尝试制作堆外内存缓冲区。我想要非常大的缓冲区(比如 10GB)。 我听说 jvm heap 有时会因为 full GC 而冻结。所以,我尝试用 java.nio.ByteBuffer 做缓冲区。
但是,我遇到了很大的困难!
java.nio.ByteBuffer.allocateDirect(int size)
函数只支持整数。但我想要更大的尺寸。我能做些什么?我该怎么办?请帮我堆叠溢出大师。
我的开发环境是macbook pro, i7 2.4ghz, 16gb ddr3, 250ssd, osx 10.9, eclipse kepler x64。
我尝试解决问题:
ByteBuffer buffer = ByteBuffer.allocateDirect(1024*1024*2000);
ByteBuffer buffer1 = ByteBuffer.allocateDirect(1024*1024*2000);
ByteBuffer buffer2 = ByteBuffer.allocateDirect(1024*1024*2000);
ByteBuffer buffer3 = ByteBuffer.allocateDirect(1024*1024*2000);
但这行不通。只再分配内存1024*1024*2000
请帮帮我。
【问题讨论】:
标签: java nio bytebuffer