简体   繁体   English

帮助加载大量数据

[英]Help with loading large amount of data

I have an array with 500 objects, I have been told that this is not a smart idea because of the huge amount of memory it takes. 我有一个包含500个对象的数组,有人告诉我这不是一个明智的主意,因为它需要占用大量内存。 I was told that Core Data SQLite would be good for me to load just one of these objects instead of all of them at once. 有人告诉我Core Data SQLite对我来说只加载这些对象之一,而不是一次加载所有对象是一件好事。 Here's my situation though, I'm not sure if core data would work here 不过这是我的情况,我不确定核心数据是否可以在这里工作

My array basically chooses a random Nib file to load, the program chooses a random index object, and then goes off of that go load the corresponding Nib file. 我的数组基本上选择了一个随机的Nib文件加载,程序选择了一个随机索引对象,然后从该加载相应的Nib文件中删除了。

Would I be able to do this with core data? 我能否使用核心数据来做到这一点? It seems like having all objects loaded into the array all at once is the only way to get this to work. 似乎一次将所有对象全部加载到数组中是使它起作用的唯一方法。 Does anyone know If core data could do something like this? 有谁知道核心数据是否可以做这样的事情?

I'm very new to core data, and seem to be very confused about it. 我对核心数据非常陌生,似乎对此非常困惑。 Also if someone could point me to a well know tutorial of it, that would be nice too :) 另外,如果有人可以给我指出一个众所周知的教程,那也很好:)

Thanks, Jacob 谢谢,雅各布

500 objects is not much. 500个对象不多。 Even a pretty complex object like UITableView has an instance size of 648bytes, this size changes by OS version but you get the idea. 即使像UITableView这样的非常复杂的对象,其实例大小也为648bytes,该大小随OS版本的不同而变化,但是您可以理解。 Even your quite modest class would not get over 1000 bytes. 即使是相当普通的类也不会超过1000个字节。 Leaving you at less than half a megabyte of ram. 剩下的内存不到一半兆字节。

On top of that you have to add the space for objects in your ivars. 最重要的是,您必须为ivars中的对象添加空间。 But I doubt that a puny 500 objects is a problem. 但是我怀疑一个微不足道的500个对象是一个问题。

Have you checked the logs to see if you get any memory warning notifications? 您是否检查了日志以查看是否收到任何内存警告通知?

Have you run the app with Instruments to measure the real memory impact you have? 您是否已使用Instruments运行该应用程序以衡量您对实际内存的影响?

Do all these before you begin implementing a solution to a problem you might not have. 在开始实施可能没有的问题的解决方案之前,请执行所有这些操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM