由于内存管理(使用 Core Data)导致的崩溃问题
我正在使用核心数据。从那里我
使用 NSOperation 检索 10000 多个数据,我在 UITableView 上显示大量数据。
但正如我在 XCode Instruments 中看到的那样,我的内存使用量不断增加,
这就是原因,崩溃活动存在于设备中而不是模拟器中
有人想对此发表评论吗?
I am using Core Data. From there i am retrieving 10000+ data
Using NSOperation, i am displaying huge data on UITableView.
but as i can see in XCode Instruments my memory usage continuously increasing
thats the reason, crashing activity is there in device not in simulator
Any one would like to comment on this ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不要一次检索 10000 个对象。
使用 NSAutoreleasePool 并以某个一致的间隔刷新池(间隔通过测试确定)。
每 N 次迭代:
这将在导入期间降低内存使用量。
Don't retrieve 10000 objects at once.
Use the NSAutoreleasePool and flush the pool at some consistent interval (interval to be determined via testing).
Every N iterations:
This will keep your memory usage down during import.
模拟器拥有几乎无限的内存,因为它使用 Mac 的内存,因此甚至可以交换到硬盘。另一方面,iDevice 的内存非常有限。
从你的描述来看,并不清楚你做错了什么。由您来分析它,使用 Instruments 您已经走在了良好的道路上。使用 Instruments 的“Heapshot 分析”来查找应用程序内存泄漏的位置。最近 bbum 写了一篇关于如何使用它的好文章:http://www.friday.com/bbum/2010/10/17/when-is-a-leak-not- a-leak-using-heapshot-analysis-to-find-undesirable-memory-growth/ 。 Apple 工程师在 WWDC 上还有一个关于使用 Instruments 的精彩视频,值得观看:http://developer。 apple.com/videos/wwdc/2010/
Simulator has practically unlimited memory as it uses Mac's memory thus can even swap to hard drive. iDevice has on the other side very limited memory.
From your description it's not clear what you are doing wrong. It's up to you to analyse it, with Instruments you are already on a good way. Use Instruments's "Heapshot analysis" to find where your application is leaking memory. Recently bbum wrote a nice article about how to use it : http://www.friday.com/bbum/2010/10/17/when-is-a-leak-not-a-leak-using-heapshot-analysis-to-find-undesirable-memory-growth/ . There's also a nice video from WWDC by Apple's engineers about using Instruments worth watching : http://developer.apple.com/videos/wwdc/2010/