开发者

didReceiveMemoryWarning not being called in active app

开发者 https://www.devze.com 2023-04-02 16:27 出处:网络
I have an app that is using a lot of data and when I watch the console I see the following lines then then app is killed.

I have an app that is using a lot of data and when I watch the console I see the following lines then then app is killed.

Sep  6 13:37:35 unknown SpringBoard[29] <Warning>: Received memory warning. Level=1
Sep  6 13:37:35 unknown configd[25] <Notice>: jetsam: kernel memory event (90), free: 556, active: 3993, inactive: 1967, purgeable: 0, wired: 15073
Sep  6 13:37:35 unknown SpringBoard[29] <Warning>: Received memory warning. Level=2
Sep  6 13:37:35 unknown configd[25] <Notice>: jetsam: kernel memory event (95), free: 556, active: 1889, inactive: 944, purgeable: 0, wired: 15088

That makes sense to me, the part that doesn't make sense is that my app delegate does not receive the applicationDidReceiveMemoryWarning message and my view controllers do not receive didReceiveMemoryWarning.

开发者_StackOverflow中文版

Has anyone seen this before or have any suggestions to help me figure out the issue. This is happening when the app is visible so it is not in the background. If it makes any difference I am working with an iPad 1

Thanks in advance!


I have seen this when running on the iPad device (although not on iPhone/iPod). I'm still looking for alternatives, but my current solution is to just force a low memory warning on the device based on a timer (placed in my app delegate, in the "didFinishLaunchingWithOptions") method:

// iPad doesn't seem to get the low memory warnings correctly - it just eventually crashes.  We're going to force them here every 20 seconds.
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    [NSTimer scheduledTimerWithTimeInterval:20.0 target:[UIApplication sharedApplication] selector:@selector(_performMemoryWarning) userInfo:nil repeats:YES];

This definitely has a smell to it, and I'm not sure whether Apple will accept it. However, it DOES seem to make my iPad work correctly now.

0

精彩评论

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