Your app is crashing because Jetsam (a.k.a memorystatus), which is iOS's low memory condition handler, kills it (this is similar to Linux's OOM and Android's LowMemory Killer). What you are seeing is the memory snapshot. Allow me to explain:
Free pages: 958 - how much free physical memory (in multiples of 4K)
Active pages: 2673 - how many pages in physical memory have recently been used
Inactive pages: 2118 - how many pages in physical memory have NOT recently been used
Throttled pages: 101092 - how many pages are subject to throttling (long story, irrelevant here)
Purgeable pages: 0 - how many pages can be kicked out, on low memory condition
Wired pages: 22186 - how many pages are resident locked, mostly for kernel purposes, or shared libraries
Your app has the unfortunate and dubious honor of having the most resident memory (by orders of magnitude, compared to others). So when the low memory condition occurs - some app wanting to malloc()
a large chunk, and not enough free pages remain - Jetsam simply chooses the top memory and -- boom. Kill -9
. Hence, no debug dump, etc. iOS has no swap, so there's no way to dump processes on the swap to clear up memory. The only way is out. Death.
What you can do about it:
Before Jetsam kills you, there is usually a low memory notification via an event, which the Obj-C runtime translated into the -didReceiveMemoryWarning
. So handle it. From what you're describing, you might also want to release the UIView
s. Those consume a LOT of memory.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…