我正面临着一个无辜地创造的问题。所以,我使用这个JSON来存储使用SnappyDB的对象并存储该对象,因为用户可以在上线时将此JSON发送到服务器。如果他处于离线状态,则存储该对象以便稍后发送。
我的错误是存储准备发送的对象,例如,我存储了包含图像的基本64的JSON。现在我知道我的错误了,我已经修复了存储图像路径并在对象发送时进行转换。
无论如何,我试图在这里解决的真正问题是设备中有一个成功存储的对象,但是当我尝试访问它时我得到OutOfMemoryError
,即我没有在序列化时遇到任何问题,但现在我在反序列化过程中遇到了问题。有什么我可以做的来恢复这个对象,或者我可以认为它丢失了吗?
P.S。:我没有在这里粘贴代码,因为它很简单,我很多时候都解决了这个问题。基本上我使用通用的Jackson mixin
以下是错误日志:
Fatal Exception: java.lang.OutOfMemoryError: Failed to allocate a 596370 byte allocation with 433384 free bytes and 423KB until OOM
at java.lang.StringFactory.newStringFromChars(StringFactory.java)
at java.lang.AbstractStringBuilder.toString(AbstractStringBuilder.java:629)
at java.lang.StringBuilder.toString(StringBuilder.java:663)
at com.fasterxml.jackson.core.util.TextBuffer.contentsAsString(TextBuffer.java:349)
at com.fasterxml.jackson.core.json.ReaderBasedJsonParser.getText(ReaderBasedJsonParser.java:235)
at com.fasterxml.jackson.databind.deser.std.StringDeserializer.deserialize(StringDeserializer.java:29)
at com.fasterxml.jackson.databind.deser.std.StringDeserializer.deserialize(StringDeserializer.java:12)
at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:523)
at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:95)
at com.fasterxml.jackson.databind.deser.impl.BeanPropertyMap.findDeserializeAndSet(BeanPropertyMap.java:285)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:248)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:136)
at com.fasterxml.jackson.databind.deser.std.ObjectArrayDeserializer.deserialize(ObjectArrayDeserializer.java:156)
at com.fasterxml.jackson.databind.deser.std.ObjectArrayDeserializer.deserialize(ObjectArrayDeserializer.java:17)
at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:523)
at com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:101)
at com.fasterxml.jackson.databind.deser.impl.BeanPropertyMap.findDeserializeAndSet(BeanPropertyMap.java:285)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:248)
at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:169)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:144)
at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer._deserializeTypedForId(AsPropertyTypeDeserializer.java:124)
at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer.deserializeTypedFromObject(AsPropertyTypeDeserializer.java:95)
at com.fasterxml.jackson.databind.deser.AbstractDeserializer.deserializeWithType(AbstractDeserializer.java:131)
at com.fasterxml.jackson.databind.deser.impl.TypeWrappedDeserializer.deserialize(TypeWrappedDeserializer.java:42)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3564)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2580)
at com.ntxdev.zuptecnico.storage.BaseService.getObject(BaseService.java:31)
由于它是一个Android应用程序,因此线程How to deal with “java.lang.OutOfMemoryError: Java heap space” error (64MB heap size)对我不起作用。