我创建了一个原型如下:
syntax = "proto3";
option java_package = "cn.com.cennavi.oem.common";
option java_outer_classname = "RInfoPB";
message RInfo {
string dataVersion = 1;
map<string, MapValue> map = 2;
}
message MapValue {
map<string, string> map = 1;
}
我将数据(240mb)放入 pb 对象并将对象序列化为本地文件(590mb)。规模翻了一番。为什么会这样?
接下来,我将本地文件转换为 pb 对象,Xms 和 Xmx 都是 5g。最后,我得到了一个内存不足的异常。
用法有什么问题吗?
顺便说一句:protobuf.jar 的版本是 3.6.0
请帮忙~~
堆栈跟踪
[root@localhost test]# java -Xms5g -Xmx5g -jar ProtobufTester.jar /APP/midmif/out_bak/Rbeijing_dir322.rinf
解压缩完成, 耗时 [488] ms, 大小 [621043338] ~
Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded
at com.google.protobuf.CodedInputStream$ArrayDecoder.readStringRequireUtf8(CodedInputStream.java:845)
at com.google.protobuf.WireFormat$Utf8Validation$2.readString(WireFormat.java:196)
at com.google.protobuf.WireFormat.readPrimitiveField(WireFormat.java:245)
at com.google.protobuf.FieldSet.readPrimitiveField(FieldSet.java:581)
at com.google.protobuf.MapEntryLite.parseField(MapEntryLite.java:135)
at com.google.protobuf.MapEntryLite.parseEntry(MapEntryLite.java:182)
at com.google.protobuf.MapEntry.<init>(MapEntry.java:106)
at com.google.protobuf.MapEntry.<init>(MapEntry.java:50)
at com.google.protobuf.MapEntry$Metadata$1.parsePartialFrom(MapEntry.java:70)
at com.google.protobuf.MapEntry$Metadata$1.parsePartialFrom(MapEntry.java:64)
at com.google.protobuf.CodedInputStream$ArrayDecoder.readMessage(CodedInputStream.java:923)
at cn.com.cennavi.oem.common.RInfoPB$RInfo.<init>(RInfoPB.java:142)
at cn.com.cennavi.oem.common.RInfoPB$RInfo.<init>(RInfoPB.java:109)
at cn.com.cennavi.oem.common.RInfoPB$RInfo$1.parsePartialFrom(RInfoPB.java:906)
at cn.com.cennavi.oem.common.RInfoPB$RInfo$1.parsePartialFrom(RInfoPB.java:1)
at com.google.protobuf.AbstractParser.parsePartialFrom(AbstractParser.java:163)
at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:197)
at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:209)
at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:214)
at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:49)
at cn.com.cennavi.oem.common.RInfoPB$RInfo.parseFrom(RInfoPB.java:414)
at cn.com.cennavi.Toolkit.protobuf.Deserialize.main(Deserialize.java:18)