如何25000对象存储在Android的集合(HashMap的,LinkedHashMap的,ArrayList中,图) [英] how to store 25 thousand objects in Android Collection (HashMap, LinkedHashMap, ArrayList, Map)

查看:323
本文介绍了如何25000对象存储在Android的集合(HashMap的,LinkedHashMap的,ArrayList中,图)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

其实我收到25000从Web服务JSON对象,我用杰克逊来分析他们,当我想有在集合(HashMap的,LinkedHashMap的,数组列表,地图),不幸的是用所有的人我在Android中的内存不足异常运行到。可有人为我的情况下,巨大的对象之前尝试这一点,可能会高达最大50000对象。那么,如何处理以更好的方式。我试图通过延长上述集合来创建一些自定义的对象,但我不是很不够好,得到了这一点。请任何建议。

Actually I am getting 25 thousand of JSON objects from a web service and i am using Jackson to parse them and when i am trying to have that in collection(HashMap, LinkedHashMap, Array List, Map) and unfortunately using all of them i am running into "Out Of memory Exception in Android".. Can someone experimented this before with huge objects for my case it may go upto 50 thousand objects at maximum. so how do i handle in a better way. I have tried to create some customized objects by extending the above collections but i am not quite well enough to get that out. Please any suggestions.

推荐答案

如果你有足够的内存50000或50亿个对象是没有问题的。如果你有有限的内存,一个选择是将值存储在磁盘上如存储卡。可以有每个键一个文件和该文件的内容是值。如果值小(小于1 KB),则可能合并值以某种方式来减少使用量。由于数据是文本,你可以COM preSS的数据,以减少磁盘的使用情况也是如此。

If you have enough memory 50 thousand or 50 million objects is not a problem. If you have limited memory, one option is to store the values on disk e.g. a memory card. You can have one file per key and the contents of the file are the value. If the values are small (< 1 KB) you might combine the values in some manner to reduce usage. As the data is text, you could compress the data to reduce disk usage as well.

您可以保持最新值的缓存。该缓存可能是最后10 - 1000键/值,使他们能够迅速地与磁盘上的其余部分进行访问

You could keep a cache of recent values. This cache could be the last 10 - 1000 key/values so they can be accessed quickly with the rest on disk.

如果您后玉米pressing中的数据,它不适合于装置的存储,它很可能将需要存储移动到服务器,并提取所需通过网络的信息。

If you after compressing the data, it won't fit on the storage of the device, it is likely you will need to move the storage to a server and extract the information you need over a network.

这篇关于如何25000对象存储在Android的集合(HashMap的,LinkedHashMap的,ArrayList中,图)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆