My app crashes and closes down and there is very little information as to why

前端 未结 1 1733
时光说笑
时光说笑 2020-12-05 03:33

I have a crash and would greatly appreciate some advice on how to find and fix the problem. The Game simply shuts downs. When the app is attached and running in the debugger

1条回答
  •  天命终不由人
    2020-12-05 04:16

    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 UIViews. Those consume a LOT of memory.

    0 讨论(0)
提交回复
热议问题