是否可以强制终止 iOS 上的后台应用程序?
我编写了一个处理视频的应用程序。众所周知,视频处理在处理高清分辨率时需要大量内存。我的应用程序似乎总是崩溃。但实际上我 100% 确定我的代码中没有内存泄漏。仪器显示无泄漏。
一开始,我启动一个 OpenGLES 视图和视频引擎。在很短的时间内,内存消耗很高,但在初始化完成后下降到正常水平。在此期间我总是收到内存警告。通常这没有问题。但是,如果我有很多处于挂起模式的应用程序正在运行,则该应用程序似乎会崩溃。观察崩溃日志并使用调试器显示,我只是内存不足。
我的客户在我的支持邮件中充斥着“应用程序崩溃”的邮件。但我确实知道,他们在后台运行了太多应用程序,因此没有剩余内存。我认为让客户在运行应用程序之前必须关闭后台任务是一种糟糕的编程风格。
根据这篇文章这是一个常见的问题。
我的问题是:是否可以告诉操作系统需要大量内存,因此操作系统应该终止一些挂起的应用程序?这些内存问题让我发疯,因为它不是我可以修复的错误。
I've written an app which is handling videos. As we know, video processing takes a huge amount of memory while dealing with HD resolution. My App always seemed to crash. But actually I am 100% sure, that there is no memory leak in my code. Instruments is showing no leak.
At the beginning I am startin up one OpenGLES view and the video engine. For a very short time the memory consumption is high, but falling down to normal level after the initializations are done. I am always getting memory warnings during this period. Normally this is no problem. But if I have a lot of apps in suspended mode running, the App seems to be crashing. Watching into the crash log and using the debugger shows up, that I am only running out of memory.
My customers are flooding my support mail with "app is crashing" mails. But I do know, that they have too much Apps running in the background, so there is no memory left to go. I think it's bad style programing saying the customer that he has to close Background tasks before running the app.
According to this post this is a common problem.
My question is: Is it possible to tell the OS that one needs a lot of memory so the OS should terminate some suspended Apps? This memory stuff makes me crazy, because it's no bug I could fix.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不可以。如果不调用 API,就不可能影响沙箱之外的任何内容。不存在影响公共 API 中其他进程的方法。
您是否尝试过最小化内存使用量?根据我的经验,一旦抛出内存警告,应用程序一旦进入后台,即使内存使用量下降,也更有可能出现问题。
如果您正在使用 OpenGLES 和纹理,如果您还没有 压缩你的纹理。内存分配峰值的具体原因是什么?
No. It is not possible to affect anything outside of your sandbox without API calls. None exist for affecting other processes in the public API.
Have you tried to minimize your memory usage? In my experience once a memory warning it thrown apps can be more likely to have problems once they are in the background, even when memory usages drops.
If you are using OpenGLES and textures, if you haven't already compress your textures. What is the specific cause of your memory allocation spike?