开发者

iPhone app gets killed due to low memory condition even though I don't think this is the case

开发者 https://www.devze.com 2023-03-08 07:09 出处:网络
My iphone app gets killed by system when I run it on a device. This is what it says in the device console:

My iphone app gets killed by system when I run it on a device. This is what it says in the device console:

Mon May 23 22:17:23 unknown configd[23] <Notice>: jetsam: kernel memory event (90), free: 372, active: 1393, inactive: 1254, purgeable: 39, wired: 9550
Mon May 23 22:17:23 unknown SpringBoard[25] <Warning>: Memory level is urgent (10%) and there are no background apps to ask to exit.
Mon May 23 22:18:25 unknown com.apple.launchd[1] <Notice>: (UIKitApplication:com.apple.mobilephone[0x9229]) Exited: Killed
Mon May 23 22:18:25 unknown com.开发者_开发知识库apple.launchd[1] <Notice>: (UIKitApplication:my.bogusfirm.bogusappname[0xf789]) Exited: Killed

When I run the app with Instruments, I have about 1.43Mb of live bytes and checking for leaks reveals about 4Kb of leaked objects but they leak in the beginning and there seems to be no cumulative leaks after that. Still the app gets killed at some point (after a couple of minutes use). My app is pretty simple with 10 or so views been navigated back and forth.

My device is a 1st gen iPhone with 8Gb of mem. I have rebooted the device but that does not help.

Any ideas?

UPDATE: I took care of the leaks and there are none anymore. However, the app still gets killed when running it with Instruments.


you have to respond to it (and implement what you can), and expect getting killed when the system 'just needs memory'; it's not to do with how little you use.

some devices have very low physical memory and total memory consumption is out of your control.

make sure you keep your memory low, respond to memory warnings, and clean up in viewDidUnload.

it's likely that each new OS will require more memory, and developers will use new features (consuming more memory in many cases). so the issue will likely become more frequent over time (until everyone buys a device with more memory).


If you have a jailbroken device you can turn on the physical memory display in the status bar, not that I condone jailbreaking but it IS useful in this instance.

Bear in mind that there are other things running on the device which use memory. If you use ImageNamed calls etc, then the system caches them and this memory usage is outside of the memory shown allocated to your app in Instruments.

Also a reboot of the device can clear up and large memory usage left behind from large web browsing, large image caching etc.

0

精彩评论

暂无评论...
验证码 换一张
取 消