4

I am new here . Sorry if I this question is being repeated but I have a slightly different issue than the others.

My app crashes randomly after certain amount of time interval without any error logs or stack trace. I suspect it's an memory issue . I have the following questions :

1.) How to get stack trace (I have tried NSZombie enabled and NSUnacughtExcpetion handler) but didn't worked

2.) I get Memory warning frequently in my app. How do I confirm whether it's the prime suspect for the above issue? (I have used Leaks, my app crashes when it has just 4Mb usage so I am not quite sure whether memory leak is causing it my app to crash. I know certain application which take heap memory more than 4MB .)

3.) What is the upper limit for Memory leak for an application in iOS before app crashes ?

4.) Would ARC help me in this situation ?

Also, I have tried to debug issue using NSLog statements but since it crashes randomly , it would be hard for me to detect the root cause using this technique.

Any ideas would be or help would be really appreciated

Community
  • 1
  • 1
Kunal Balani
  • 4,739
  • 4
  • 36
  • 73
  • I have had random crashes take place on the device but no the simulator because of memory size. I was loading in lots of pictures. It blew the app right up on the device and I didn't get any information. So question is, is this happening on the device or simulator? iPad or iPhone? Which version of the OS? What version of Xcode, and what kind of mac? – Kaili Jun 04 '12 at 20:52
  • @Joe how do you get to know Memory warning level? – Kunal Balani Jun 04 '12 at 20:55
  • As with many crashes its not as random as you feel. Try to hunt down any and every possible connector and update your post so we can get a better idea of what is actually causing it. – Ryan Poolos Jun 04 '12 at 20:56
  • Also if the device or simulator is running with xcode open and in debug mode it will show the trace in the console window. – Kaili Jun 04 '12 at 20:56
  • @Shadow thanks for a quick reply . I am developing app for iPad . My app works fine on simulator . I see warnings in simulator as well but app does not crash . I am using MAc Osx 10.7.3 ... iPad simulator 4.3 . – Kunal Balani Jun 04 '12 at 21:00
  • @KunalBalani: Use Instrumentation to look at memory, and see whether there is anything that shouldn't be there keep staying there, or the number of object of certain class which should have decreased but not. – nhahtdh Jun 04 '12 at 21:46

5 Answers5

8

My app crashes randomly after certain amount of time interval without any error logs or stack trace. I suspect it's an memory issue.

To confirm that it's a memory issue, sync your device with iTunes,and look in ~/Library/Logs/CrashReporter/MobileDevice/ for a files with LowMemory in their name. If you see (jettisoned) next to your app name, that confirms it was killed by iOS for using too much memory.

The only other way an app could exit without leaving a crash report is if it erroneously called exit().

For more information, see "Debugging Deployed iOS Apps", and "Understanding and Analyzing iOS Application Crash Reports".

Vincent Gable
  • 3,455
  • 23
  • 26
  • awesome .... I was looking for some concrete proof like this ... Yes I see that jettisoned .. :( I thought I my app can have enough memory but I was wrong ... – Kunal Balani Jun 04 '12 at 22:32
  • Yeah the thing that leads you into a trap on the simulator is that it won't crash when you use more memory than the device has, it's a SIMulator not an EMUlator. Which is unfortunately but at least stuff runs fast in it. I'm glad someone was able to answer I don't have my mac handy at work and plain couldn't remember where to look :) – Kaili Jun 05 '12 at 17:32
4

Not sure but reading the registers might help.

First go to Exceptions tab and 'Add Exception Breakpoint' using the + at the bottom left corner. enter image description here

Then when the app crashes click on "0 objc_exception_throw" under Thread 1 enter image description here

Finally in the console enter:

  • register read (you should get a list of registers)

  • po $rax (normally the exception is in 'rax')

    (you should see the exception output on the console)

Hope this helps.

Community
  • 1
  • 1
shrishaster
  • 682
  • 9
  • 21
3

That does sound like maybe the device is running low on memory and shutting you down. There's lots of threads on stackoverflow on debugging memory warnings.

This one talks a little about what to look for when using the Instruments tool.

Here is an explanation of how to get the memory warning level, and what the codes mean.

There is no fixed memory limit on iPhones. I've asked Apple support representatives this question, and they wouldn't give me a fixed answer (probably because the algorithm does not actually enforce any one hard limit for a 3rd-party app).

And, yes, ARC can be a wonderful thing. In your situation, you might have to rework a lot of code to make it all ARC-compliant, but ARC is definitely a useful feature, and can produce programs with fewer memory problems, with less work by the coders (leaving you more time to fix other problems!)

Community
  • 1
  • 1
Nate
  • 31,017
  • 13
  • 83
  • 207
  • thank you ... I appreciate it .. I get critical memory warnings in my app ... this indicates I am on correct path . .. thank you once again – Kunal Balani Jun 04 '12 at 21:33
1

I recommend instrument https://developer.apple.com/library/mac/#documentation/developertools/conceptual/InstrumentsUserGuide/AboutTracing/AboutTracing.html

iArezki
  • 1,273
  • 2
  • 17
  • 29
  • I used Leaks ... It's very useful. I can detect memory leaks . My memory usage goes on increasing but my app crashes when the overall allocation bytes reaches 4.7MB. ...thats should not crash my app !! – Kunal Balani Jun 04 '12 at 21:07
0

In my case i closed all other apps and it started working normally, maybe it was a memory issue

SoliQuiD
  • 2,093
  • 1
  • 25
  • 29