当我尝试使用 Chronicle Map 时,我遇到了一些我无法解决的错误。在我最近的调试尝试中,我将流读入内存以检查字节是什么,但它使整个 JVM 崩溃。
EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000005079c1b0, pid=7128, tid=10476
我正在使用 Kryo 来写入我的数据,并使用BytesMarshaller<T>
如下所示的每种类型将其读回:
public void write(Bytes bytes, T obj)
{
ByteArrayOutputStream baos = null;
try (ByteArrayOutputStream baos2 = new ByteArrayOutputStream())
{
try (Output output = new Output(baos2))
{
kryos.get().writeObject(output, obj);
baos = baos2;
}
}
byte[] byteArray = baos.toByteArray();
OutputStream out = bytes.outputStream();
{
out.write(byteArray);
}
}
写和读:
public T read(Bytes bytes)
{
ByteArrayOutputStream baos = null;
try (ByteArrayOutputStream baos2 = new ByteArrayOutputStream())
{
InputStream in = bytes.inputStream();
{
ByteStreams.copy(in, baos2);
baos = baos2;
}
}
try (Input input = new Input(baos.toByteArray()))
{
return kryos.get().readObject(input, cls);
}
}
我试过关闭流但遇到完全相同的问题。
当我开始迭代一个键集时会发生这个问题 - 不确定这是否相关。
这是我的堆栈跟踪:
j com.google.common.io.ByteStreams.copy(Ljava/io/InputStream;Ljava/io/OutputStream;)J+28
j uk.org.jaggard.dao.memory.KryoBytesMarchaller.read(Lnet/openhft/lang/io/Bytes;)Ljava/lang/Object;+28
j net.openhft.chronicle.hash.serialization.internal.BytesReaders$SimpleBytesReader.read(Lnet/openhft/lang/io/Bytes;J)Ljava/lang/Object;+5
j net.openhft.chronicle.map.VanillaChronicleMap$Segment.getEntry(Lnet/openhft/chronicle/map/VanillaChronicleMap$SegmentState;J)Ljava/util/Map$Entry;+70
j net.openhft.chronicle.map.VanillaChronicleMap$EntryIterator.next()Ljava/util/Map$Entry;+115
j net.openhft.chronicle.map.VanillaChronicleMap$EntryIterator.next()Ljava/lang/Object;+1
j java.util.AbstractMap$1$1.next()Ljava/lang/Object;+4