iphone killing background apps

邮差的信 提交于 2019-12-11 08:58:35

问题


Is there a way to kill background apps?

I have an app that I am working on that records a sound and then plots it out on a scroll view the problem I had with it is it crashes if the recording is too long because it runs out of memory trying to plot it. My fix to this is to monitor the amount of free memory and predict how much memory usage plotting will take and stop the recording just before there is not enough. The problem with that is the more apps I have running in the background the sooner it stops recording instead of killing background apps to make space the way that ios does before a didRecieveMemoryWarning. To restate my Question how can I kill these background apps? Will Apple frown upon this?


回答1:


You want to kill other background apps programmatically from your foreground app? I suspect Apple would frown on that.

In theory you can get their process id's from sysctl and send them a SIGKILL to terminate them, but iOS won't let you get info about other processes unless you are root (which means jailbreaking).




回答2:


iOS will start terminating unused background apps itself at the same time when it starts sending you memory warnings. But you shouldn't be getting memory warnings at all, try to fix your memory management instead.




回答3:


Killing background apps do not solve your problem. Even all other apps are killed, your apps will still crash after a while.

Consider use a small buffer to store those data and write them regularly to storage. When user need to scroll back and read older records, read them back from storage. By limiting the window size, the app will only use certain amount of memory.



来源:https://stackoverflow.com/questions/7020691/iphone-killing-background-apps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!