diff --git a/runtime/engine/src/main/java/io/aklivity/zilla/runtime/engine/internal/layouts/BufferPoolLayout.java b/runtime/engine/src/main/java/io/aklivity/zilla/runtime/engine/internal/layouts/BufferPoolLayout.java index d828d5c4ac..a775a486e4 100644 --- a/runtime/engine/src/main/java/io/aklivity/zilla/runtime/engine/internal/layouts/BufferPoolLayout.java +++ b/runtime/engine/src/main/java/io/aklivity/zilla/runtime/engine/internal/layouts/BufferPoolLayout.java @@ -101,6 +101,18 @@ public BufferPoolLayout build() final MappedByteBuffer mapped = mapExistingFile(layoutFile, "bufferPool"); + int slotCapacity = this.slotCapacity; + int slotCount = this.slotCount; + + if (readonly) + { + final int totalLength = (int) layoutFile.length(); + final int slotCountIndex = totalLength - Integer.BYTES; + + slotCount = mapped.getInt(slotCountIndex); + slotCapacity = slotCountIndex / slotCount - Long.BYTES; + } + return new BufferPoolLayout(new DefaultBufferPool(slotCapacity, slotCount, mapped)); } }