Why did my application just use about 36 MB of memory, but am still getting a low memory warning?

I use tools to track the use of my application in memory, in the memory monitor, I found that the real memory is below 36 MB, and in most cases it is only 32 MB, but I still get warnings about low memory in the organizer and crashed.

Incident Identifier: CFEF044E-E839-4DB7-9ED6-E22CD92B9171 CrashReporter Key: 80954447762f1882da7df309d5493cf8647f4c8b OS Version: iPhone OS 3.2 (7B367) Date: 2010-08-10 15:21:25 +0800 Free pages: 593 Wired pages: 18705 Purgeable pages: 1664 Largest process: iPad4HB Processes Name UUID Count resident pages iPad4HB <51ec4f748adb8d99e4456ba49644e516> 27182 (jettisoned) (active) debugserver <6f10136b8d55ad8cbd29c09a402b1f94> 149 syslog_relay <4ceaed776d2df957fa130712f4ef21d0> 70 notification_pro <4c9a7ee0a5bbe160465991228f2d2f2e> 71 lsd <a4d852c1c8da2b3d231bdc90887b52ba> 143 apsd <f655e615956fa9881fd423d762791e7d> 197 notifyd <5e9d5bee7c3eae1c8b494c79eb11406e> 62 BTServer <64e4a6ea6b1240db2331e05a29caa862> 132 CommCenter <97bf297944ac4bde19bcee96dd23bd5f> 191 SpringBoard <c7a5904c12db7b14334a4edaa4cabaa9> 4844 (active) accessoryd <b4e1403f53e4c7b53b0ec833007f6589> 122 configd <aca9fa3380322669164fd6b1a3864300> 374 fairplayd.K48 <2d997ffca1a568f9c5400ac32d8f0782> 86 locationd <dd1ea88105c62173908ce767db5c4d37> 654 mDNSResponder <820560222d47a1f2a0dce98a7f8a9721> 112 mediaserverd <ea8bac28b06fe3980fdd44b5caceb563> 5931 lockdownd <497fd54c79a680bf29f5d9320f514613> 579 MobileStorageMou <c277b79c2157c4dc5cfc5c3ca35bd5f2> 76 syslogd <66247e305d5c0bf6f1ce1cc950653263> 80 ptpd <83de0f774bd6553d513ae9e19b0f9b56> 233 launchd <66972eee4d865c4383b33d985d22994b> 72 **End** Tue Aug 10 15:12:05 hokudaiaoniaowangruande-iPad SpringBoard[26] <Warning>: Received memory warning. Level=1 Tue Aug 10 15:12:05 hokudaiaoniaowangruande-iPad iPad4HB[107] <Warning>: Received memory warning. Level=1 Tue Aug 10 15:12:20 hokudaiaoniaowangruande-iPad iPad4HB[107] <Warning>: playing Tue Aug 10 15:12:32 hokudaiaoniaowangruande-iPad iPad4HB[107] <Warning>: playable Tue Aug 10 15:12:32 hokudaiaoniaowangruande-iPad iPad4HB[107] <Warning>: playing Tue Aug 10 15:12:37 hokudaiaoniaowangruande-iPad iPad4HB[107] <Warning>: playing Tue Aug 10 15:13:28 hokudaiaoniaowangruande-iPad iPad4HB[107] <Warning>: playable Tue Aug 10 15:13:28 hokudaiaoniaowangruande-iPad iPad4HB[107] <Warning>: playing Tue Aug 10 15:13:44 hokudaiaoniaowangruande-iPad iPad4HB[107] <Warning>: playing Tue Aug 10 15:14:11 hokudaiaoniaowangruande-iPad iPad4HB[107] <Warning>: playable Tue Aug 10 15:14:11 hokudaiaoniaowangruande-iPad iPad4HB[107] <Warning>: playing Tue Aug 10 15:14:20 hokudaiaoniaowangruande-iPad iPad4HB[107] <Warning>: playing Tue Aug 10 15:14:50 hokudaiaoniaowangruande-iPad iPad4HB[107] <Warning>: playable Tue Aug 10 15:14:50 hokudaiaoniaowangruande-iPad iPad4HB[107] <Warning>: playing Tue Aug 10 15:14:56 hokudaiaoniaowangruande-iPad iPad4HB[107] <Warning>: playing Tue Aug 10 15:15:02 hokudaiaoniaowangruande-iPad mDNSResponder[19] <Error>: ERROR: mDNSPlatformReadTCP - recv: 60 (Operation timed out) Tue Aug 10 15:16:11 hokudaiaoniaowangruande-iPad iPad4HB[107] <Warning>: playable Tue Aug 10 15:16:11 hokudaiaoniaowangruande-iPad iPad4HB[107] <Warning>: playing Tue Aug 10 15:17:33 hokudaiaoniaowangruande-iPad iPad4HB[107] <Warning>: playing Tue Aug 10 15:17:44 hokudaiaoniaowangruande-iPad iPad4HB[107] <Warning>: playable Tue Aug 10 15:17:44 hokudaiaoniaowangruande-iPad iPad4HB[107] <Warning>: playing Tue Aug 10 15:18:01 hokudaiaoniaowangruande-iPad iPad4HB[107] <Warning>: playing Tue Aug 10 15:18:07 hokudaiaoniaowangruande-iPad iPad4HB[107] <Warning>: playable Tue Aug 10 15:18:07 hokudaiaoniaowangruande-iPad iPad4HB[107] <Warning>: playing Tue Aug 10 15:18:07 hokudaiaoniaowangruande-iPad configd[24] <Notice>: jetsam: kernel memory event (90), free: 695, active: 1734, inactive: 985, purgeable: 3456, wired: 18656 Tue Aug 10 15:18:07 hokudaiaoniaowangruande-iPad SpringBoard[26] <Warning>: Received memory warning. Level=2 Tue Aug 10 15:18:07 hokudaiaoniaowangruande-iPad iPad4HB[107] <Warning>: Received memory warning. Level=2 Tue Aug 10 15:18:07 hokudaiaoniaowangruande-iPad SpringBoard[26] <Warning>: Memory level is urgent (10%) and there are no background apps to ask to exit. Tue Aug 10 15:19:07 hokudaiaoniaowangruande-iPad iPad4HB[107] <Warning>: playing Tue Aug 10 15:19:15 hokudaiaoniaowangruande-iPad iPad4HB[107] <Warning>: playable Tue Aug 10 15:19:15 hokudaiaoniaowangruande-iPad iPad4HB[107] <Warning>: playing Tue Aug 10 15:20:02 hokudaiaoniaowangruande-iPad iPad4HB[107] <Warning>: playing Tue Aug 10 15:20:06 hokudaiaoniaowangruande-iPad iPad4HB[107] <Warning>: playable Tue Aug 10 15:20:06 hokudaiaoniaowangruande-iPad iPad4HB[107] <Warning>: playing Tue Aug 10 15:21:01 hokudaiaoniaowangruande-iPad iPad4HB[107] <Warning>: playing Tue Aug 10 15:21:06 hokudaiaoniaowangruande-iPad iPad4HB[107] <Warning>: playable Tue Aug 10 15:21:06 hokudaiaoniaowangruande-iPad iPad4HB[107] <Warning>: playing Tue Aug 10 15:21:24 hokudaiaoniaowangruande-iPad configd[24] <Notice>: jetsam: kernel termination snapshot being created Tue Aug 10 15:21:24 hokudaiaoniaowangruande-iPad com.apple.launchd[1] (UIKitApplication:com.yourcompany.iPad4HB[0x4df4][107]) <Notice>: (UIKitApplication:com.yourcompany.iPad4HB[0x4df4]) Bug: launchd_core_logic.c:3232 (24063):0 Tue Aug 10 15:21:24 hokudaiaoniaowangruande-iPad com.apple.launchd[1] (UIKitApplication:com.yourcompany.iPad4HB[0x4df4][107]) <Notice>: (UIKitApplication:com.yourcompany.iPad4HB[0x4df4]) Bug: launchd_core_logic.c:3309 (24063):0 Tue Aug 10 15:21:24 hokudaiaoniaowangruande-iPad com.apple.debugserver-44[106] <Warning>: 1 [006a/1703]: error: ::read ( 6, 0x2809f4, 1024 ) => -1 err = Bad file descriptor (0x00000009) Tue Aug 10 15:21:24 hokudaiaoniaowangruande-iPad com.apple.launchd[1] (UIKitApplication:com.yourcompany.iPad4HB[0x4df4][107]) <Notice>: (UIKitApplication:com.yourcompany.iPad4HB[0x4df4]) Bug: launchd_core_logic.c:2650 (24063):10 Tue Aug 10 15:21:24 hokudaiaoniaowangruande-iPad com.apple.launchd[1] (UIKitApplication:com.yourcompany.iPad4HB[0x4df4][107]) <Notice>: (UIKitApplication:com.yourcompany.iPad4HB[0x4df4]) Working around 5020256. Assuming the job crashed. 
+4
source share
6 answers

I think this tells you what the problem is: you are using too much memory. If the OS tells you this and you donโ€™t do anything, it can (really, do) retrieve your program from memory.

You do not publish any code so that it does not find out if you have a memory leak or just too much memory. Try using a static analyzer (in the Xcode build menu) and the Leakage part of the tools to check for leaks. If it does not find, you can simply optimize your application to use less memory.

I'm not sure where you found that 36Mb is ok. On first-generation devices, you will be knocked out of memory far above 20 MB. I donโ€™t think there is an absolute number registered, so you need to do two things: check on real devices and free up as much memory as possible when it tells you that you are using too much.

+4
source

It seems to be a memory leak. To find it, use not only the Leaks device. Highlights can also help you. Use it actively, mark heaps, compare memory usage and examine objects "still alive" (especially objects of your own classes).

Sometimes memory leaks cannot be automatically detected (using the Leaks tool). For example, imagine you have a UIImageView. This image must be created when the user touches the Create button and is destroyed when he touches the Destroy button. You can implement this behavior, as in the code below:

 - (IBAction)bCreateTouchUpInside:(id)sender { ivSomeImageView = [[UIImageView alloc] initWithImage:iSomeImage]; [self.view addSubview:ivSomeImageView]; bCreate.enabled = NO; bDestroy.enabled = YES; } - (IBAction)bDestroyTouchUpInside:(id)sender { [ivSomeImageView release]; bCreate.enabled = YES; bDestroy.enabled = NO; } 

And there will be a memory leak: it is saved twice (creation + addSubview), one-time release (release). To solve the problem, you must add [ivSomeImageView removeFromSuperview]; before reporting a live broadcast. But this leak will not be detected by the Leaks device because there is a correct pointer to your image type (the parent view stores pointers to it in the view). And the only chance to find this leak for you is to click Create for many times and see that memory usage is increasing every time.

+3
source

Are you trying to load a huge amount of data in a very short time? This is especially important when trying to start an image animation sequence. I got a crash when the memory was less than 20 MB. After researching, I found that my image sequence contained very large images, and the reason for the failure was not a full memory load. The reason was memory bandwidth.

+2
source

If you are using an older model, such as 2g or 3g, 36 megabytes is probably more than what you should play. Usually I start to receive warnings about 25 mb.

+1
source

You get memory alerts when your phoneโ€™s memory is low. Level 1 memory alerts are pretty normal. If your application crashes, perhaps because you are not handling the memory warning correctly, and not because you are using too much memory. There are two fixes:

  • Ignore memory warning (do not redirect to didReceiveMemoryWarning)
  • Correct your code
+1
source

I had a similar problem in the last project. For me, the problem was hidden in a hidden statement about saving the delegate property, which kept the save account, which caused the point of view not to be deleted.

Try this troubleshooting technique ..... presumably you might have a uinavigation controller pushing / displaying controllers.

Consider that there is something in the view that holds the save count, forcing the view to remain in memory (even if the view popped up and you issued the release statement). Another symptom (not related to this problem, but related to this, if you use all view controllers, you might even have a crash in the application.)

So, in the dealloc methods of the view controller (s), execute the log statement on the hold account of the corresponding type. (and other objects that you synthesize.) for example.

 UiNavController -Level0ViewController -(void)dealloc{ // HERE TEST FOR RETAIN COUNT OF 2 (2 = one for the alloc / one for the addSubview) DLog(@"level0view retain count: :%@",[level0view retainCount]); [level0view release]; // this will make retain count 1. [super dealloc]; -- Level0View -(void)dealloc{ DLog(@"dealloc"); // set break points here and confirm this is being called. } -- SomeImageView.h // for me my problem lied here with the infringing line below being RETAIN! it should have been assign. changing this successfully resolved app crash and memory leak. @property(retain) id delegate 

PS check DLog Karl Kroft is a very good log that gives you the class line number and hides the guff that NSLog usually adds.

+1
source

All Articles