如何处理内存不足警告 [英] How to handle low memory warning

查看:125
本文介绍了如何处理内存不足警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,下载了几个文件后,我收到了内存不足的警告.我停止了当前的下载过程.即使在那之后,应用程序也会崩溃,我假设该应用程序由于内存不足问题而崩溃.任何人都可以让我知道如何释放正在运行的应用程序中的内存.

In my app I am getting low memory warning after few files download.I stops current download process. Even after that also app crashes and I am assuming that app crashes due to low memory issue. Can any one please let me know how can I free up memory in running app.

推荐答案

听起来您正在直接将文件下载到内存中.这将是一个问题,因为您没有足够的内存来下载整个文件.

It sounds like you're downloading the files straight to memory. That will be an issue because you wont have enough memory to download the entire file.

您需要采取的策略是,在下载文件时,继续将文件的一部分写到磁盘上,从而释放内存.

The strategy you need to take is, as you download the file continue to write chunks of it out to disk, freeing up memory in doing so.

如果您使用的是NSURLSession,则可以使用一个参数轻松完成此操作.请发布您的代码以获取深入帮助.

If you are using NSURLSession there is a parameter you can use to do this for you with little effort. Please post your code for in depth help.

这篇关于如何处理内存不足警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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