由于内存管理(使用 Core Data)导致的崩溃问题

发布于 2024-10-02 03:20:11 字数 186 浏览 2 评论 0原文

我正在使用核心数据。从那里我

使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

迷雾森÷林ヴ 2024-10-09 03:20:11

不要一次检索 10000 个对象。

使用 NSAutoreleasePool 并以某个一致的间隔刷新池(间隔通过测试确定)。

每 N 次迭代:

  1. 保存您的上下文
  2. 重置您的上下文
  3. 耗尽池

这将在导入期间降低内存使用量。

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:

  1. save your context
  2. reset your context
  3. drain your pool

This will keep your memory usage down during import.

冰之心 2024-10-09 03:20:11

模拟器拥有几乎无限的内存,因为它使用 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/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文