简体   繁体   中英

Terminated due memory pressure

I got the problem when my app is running in background on my iPhone for more than 2 hours, then in Xcode often comes the error "Terminated due memory pressure". What can I do that my app runs in background without problems? Here's a screenshot of Instruments: 屏幕截图

Simply put, it's very likely not really your fault. The iOS low memory killer (a rather aggressive kernel thread by the name of Jetsam) uses "priority bands" to maintain candidate processes to kill on low memory, and virtually everyone is a candidate - with background processes being likelier than foreground ones. Jetosam中的优先乐队,来自newosxobook.com/articles/MemoryPressure.html . (Image taken from Priority bands in Jetsam, from http://newosxbook.com/articles/MemoryPressure.html )

What you can do is try to gain some more breathing room by responding to low memory events (ie implement didReceiveLowMemoryWarning) and unload any Images/UIImageViews, etc you aren't strictly requiring - even if you do a little, it helps you survive. Also, you didn't point out which UIBackgroundMode you are using - that might help (it defines app profile in kernel, thereby taming Jetsam a little).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM