目标C:应用程序获得“内存警告"级别2,并在之后不久退出 [英] Objective C: App getting Memory Warning Level 2 and exits shortly after

查看:67
本文介绍了目标C:应用程序获得“内存警告"级别2,并在之后不久退出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用从服务器获取照片图像并将其存储在一个数组中,该数组最终将显示在UITableView Controller中.

我在一个单元格中显示2张图像(768 x 768像素和100 X 100像素).

启动时,该应用程序将加载10个包含图像的单元格,用户可以使用加载更多"按钮选择加载接下来的10张照片.通常,在单击15-20次加载更多"后,我会收到一条内存警告级别= 2的消息,并且我的应用程序将终止.

这是因为显示的图像太多吗?我该如何解决这个问题?

解决方案

查看我最近的SO问题/答案.我认为这可能会有所帮助.我使用了一个名为 PNGCrush 压缩/压缩我的PNG文件,而不会降低质量.我的应用程序的内存占用从约60 Mb增至约30 MB.正如Jhaliya所说,24 MB的图像可能是导致内存警告的原因(这就是我的应用程序中发生的事情).

我的StackOverflow.com帖子

My app grabs photo images from a server and stores them in an array which will eventually be displayed in a UITableView Controller.

I am displaying 2 images in a single cell (768 by 768 pixels and 100 X 100 pixels).

At launch, the app will load 10 cells with images and the user can choose to load the next 10 photos using a "load more" button. Usually after 15-20 'load more' clicks, I will receive a memory warning level = 2 message and my app will just terminate.

Is this due to the fact that there are too many images displayed? How can I resolve this issue?

解决方案

Check out my recent SO question / answer. I think it might help a lot. I used a batch file called PNGCrush to crush / compress my PNG files without loosing quality. My app's memory footprint went from ~60 Mb to ~30 MB. As Jhaliya said, 24 MB of images is probably what's causing Memory Warnings (that's what was happening in my app).

My StackOverflow.com Post

这篇关于目标C:应用程序获得“内存警告"级别2,并在之后不久退出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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