我可以控制编年史队列消耗的最大内存吗? 我在使用Xmx1200m参数的32位java进程中遇到以下异常:
java.nio.BufferOverflowException
at net.openhft.chronicle.bytes.MappedBytes.acquireNextByteStore(MappedBytes.java:147)
at net.openhft.chronicle.bytes.MappedBytes.writeCheckOffset(MappedBytes.java:135)
at net.openhft.chronicle.bytes.AbstractBytes.compareAndSwapInt(AbstractBytes.java:165)
at net.openhft.chronicle.wire.AbstractWire.writeFirstHeader(AbstractWire.java:402)
at net.openhft.chronicle.queue.impl.single.SingleChronicleQueue$StoreSupplier.acquire(SingleChronicleQueue.java:514)
at net.openhft.chronicle.queue.impl.WireStorePool.acquire(WireStorePool.java:65)
at net.openhft.chronicle.queue.impl.single.SingleChronicleQueue.storeForCycle(SingleChronicleQueue.java:262)
at net.openhft.chronicle.queue.impl.single.SingleChronicleQueueExcerpts$StoreTailer.cycle(SingleChronicleQueueExcerpts.java:1249)
at net.openhft.chronicle.queue.impl.single.SingleChronicleQueueExcerpts$StoreTailer.moveToIndex(SingleChronicleQueueExcerpts.java:1094)
at net.openhft.chronicle.queue.impl.single.SingleChronicleQueueExcerpts$StoreTailer.moveToIndexResult(SingleChronicleQueueExcerpts.java:1080)
at net.openhft.chronicle.queue.impl.single.SingleChronicleQueueExcerpts$StoreTailer.moveToIndex(SingleChronicleQueueExcerpts.java:1073)
at net.openhft.chronicle.queue.impl.single.SingleChronicleQueueExcerpts$StoreTailer.next(SingleChronicleQueueExcerpts.java:828)
at net.openhft.chronicle.queue.impl.single.SingleChronicleQueueExcerpts$StoreTailer.readingDocument(SingleChronicleQueueExcerpts.java:808)
at net.openhft.chronicle.queue.ExcerptTailer.readingDocument(ExcerptTailer.java:41)
at net.openhft.chronicle.wire.MarshallableIn.readBytes(MarshallableIn.java:38)
at com.pingway.platform.tb.InboundQueue.pop(InboundQueue.java:74)
at com.pingway.platform.tb.RecordUpdateExecutor$1.run(RecordUpdateExecutor.java:23)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: java.lang.OutOfMemoryError: Map failed
at net.openhft.chronicle.core.OS.asAnIOException(OS.java:306)
at net.openhft.chronicle.core.OS.map(OS.java:282)
at net.openhft.chronicle.bytes.MappedFile.acquireByteStore(MappedFile.java:186)
at net.openhft.chronicle.bytes.MappedFile.acquireByteStore(MappedFile.java:141)
at net.openhft.chronicle.bytes.MappedBytes.acquireNextByteStore(MappedBytes.java:143)
... 23 more
Caused by: java.lang.OutOfMemoryError: Map failed
at sun.nio.ch.FileChannelImpl.map0(Native Method)
at sun.reflect.GeneratedMethodAccessor131.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at net.openhft.chronicle.core.OS.map0(OS.java:290)
at net.openhft.chronicle.core.OS.map(OS.java:278)
... 26 more
如果我将Xmx减少到768m,则异常将消失。
答案 0 :(得分:0)
在32位进程上运行时,您需要为内存映射留出一些空间。 1.2 GB的堆接近Win XP上可以拥有的最大堆大小(因此在更高版本的Windows上的32位仿真系统上)
您可以做的是将块/块大小从默认的64 MB减少到1 MB。这将减少内存映射的大小。
然而,更好/更简单/更快的解决方案是使用64位JVM。这将为您提供大约100,000倍的虚拟内存。
如果您还不能使用64位JVM,则可以使用与Chronicle Engine的Java客户端连接。这将允许您运行具有运行64位的Chronicle Queue的服务器,并使32位客户端访问该数据。