1

My iOS app is randomly crashing but I don't get any warning/error in the console. I think it might be a memory leak but shouldn't I receive a EXC_BAD_ACCESS error at least ?

The other thing might be a memory overloading, but I don't get any memory warning and I've just tested the app with the instruments tool.

So why does it crash without printing anything in the console ?

Thanks

UPDATE: I'm actually getting a memory warning in the instruments although I don't see the memory to increase. COuld be the cause of the crash ? How do i know where is the memory warning generated ? (See screenshot: )

enter image description here

aneuryzm
  • 63,052
  • 100
  • 273
  • 488
  • Add an exception breakpoint in Xcode – 0xSina Jul 03 '12 at 10:54
  • You can check this tuto to add the exception breakpoint: http://timroadley.com/2012/03/26/tip-exception-breakpoints – Yannick Loriot Jul 03 '12 at 10:58
  • @0xSina It didn't work, the exception is not caught – aneuryzm Jul 03 '12 at 11:36
  • @Yannick L. I've created it but nothing http://cl.ly/HoaE – aneuryzm Jul 03 '12 at 11:37
  • @Patrick Try and see if the arguments you are passing to NSString format are correct. Also, any arguments that require a nil at the end (like NSArray or NSDictionary) is correct. I've had this crash couple of times where this was the problem and I didn't get any sort of error. – 0xSina Jul 03 '12 at 11:51
  • @Patrick override UIViewController's memory warning received method. – 0xSina Jul 03 '12 at 11:55
  • @0xSina I've implemented UIViewController's didReceiveMemory and indeed it is invoked. But now ? I need to know where is the memory issue... – aneuryzm Jul 03 '12 at 12:09
  • @0xSina I haven't fully understood your previous comment. Which NSString are you referring to ? And what are you saying about NSArray and NSDictionary ? (by the way they all have nil in the end when they are initialized) – aneuryzm Jul 03 '12 at 12:11
  • @Patrick nvm, given that you are getting a low memory warning in instruments, that's probably not it anyways. What kind of stuff are you doing in your view controller that's received the memory warning? Initializing lots of large UIImage's? Unarchiving plists? etc. Also, run instruments with memory leaks on. – 0xSina Jul 03 '12 at 12:19
  • @0xSina I've run the memory leak instrument and indeed there is a leak: http://cl.ly/Hohd . From the instruments I can see the Leaked Object is a CGImage. But I don't understand, I don't see the memory increasing in the Allocations. – aneuryzm Jul 03 '12 at 12:29
  • @0xSina OK FIXED, there was an issue in the library source I was using in the view controller. Your tip about using memory leak instrument worked. iF you add as answer, I will accept it. – aneuryzm Jul 03 '12 at 13:50

2 Answers2

1

Tell your program to print a backtrace every time it receives a low memory warning.

From Apple documentation:

UIKit provides several ways to receive low-memory notifications, including the following:

  • Implement the applicationDidReceiveMemoryWarning: method of your application delegate.
  • Override the didReceiveMemoryWarning method in your custom UIViewController subclass.
  • Register to receive the UIApplicationDidReceiveMemoryWarningNotification notification.
Dustin
  • 6,783
  • 4
  • 36
  • 53
  • I'm doing what you say, but beside seeing these methods invokated, I don't see any other helpful information for the debugging. – aneuryzm Jul 03 '12 at 12:50
  • You should see the methods called that caused the low memory warning. Once you have those you should put a breakpoint inside of the notification method and step through the methods until one of them triggers the warning. – Dustin Jul 03 '12 at 12:52
0

Enable Zombie objects and try again. https://stackoverflow.com/a/8050701/1271579

Edit: If the device runs out of memory, you will recieve a few memory warnings before crashing so you should probably optimize it.

Community
  • 1
  • 1
gregorkas
  • 137
  • 5