2

My app crashes (randomly by the way) when running on the device, the crash is not reproduce-able 100% of the time. But it only seems to occur on the device, not in the simulator.

When I run in the simulator with NSZombies I never see problems. Could someone shed some light into my points below.

  • Device has limited memory, maybe it's crashing because of this.
  • What would be considered a big memory allocation that would cause a crash?
  • Would memory leaks/big allocation cause a memory corruption?
  • All my crashes are always EXC_BAD_ACCESS but like I said, never happens on simulator so I can't run zombies. (or is there another way?)

Note I have also simulated low memory warnings on the simulator to see if that's causing issues.

This is driving me nuts. Any help would be appreciated.

MrShoot
  • 843
  • 1
  • 9
  • 21
  • 1
    any reason you cant use ARC? just to rule out a memory issue. Also a major difference between the two is case sensitivity. The simulator is not case sensitive but the device is. However "normally" you would be get sigabrt errors vs exc_bad_access if it was a case problem. The only other thing to try is to run it on your phone while your phone is plugged in. so any errors output to the console. – owen gerig Jul 09 '12 at 16:47
  • Can't go to ARC because I have to support iOS 3.0 still (yeah I know it sucks). I've tried plugging it in with debugging but I can't see the zombie objects, nor count the reference count or look at a stack trace that makes sense other than the line where it crashed. I know where it crashes but I need to know which other classes released this object. – MrShoot Jul 09 '12 at 16:55
  • use breakpoints. im sure one of your objects is nil (probably released to soon) and thats whats causing the errors. Look here for placing a kind of universal breakpoint (second comment on this post: http://stackoverflow.com/a/8072273/530933) – owen gerig Jul 09 '12 at 17:02
  • I've considered that owen, but it would be pretty much impossible for me to debug like this. Reason being I populate over 200 objects and insert them inside a NSDictionary every 10 seconds. If I place a breakpoint in this call I would be sitting here for days, no exageration. My guess some of the entries inside the dictionary are being autoreleased at some point. PS: Just noticed the comment you linked actually points me to add exception breakpoints, not just any breakpoint. I will give this a try! – MrShoot Jul 09 '12 at 17:54

1 Answers1

0
I know where it crashes but I need to know which other classes released this object.

Override -[release] -[autorelease] and -[retain] for your object (or you could do this for NSObject if you didn't know which object), then log them, set breakpoints.

If you identify which object is being released at each point, add timestamps/ object IDs/retaincount to the log statement, then you might be able to throw all of the data into a spreadsheet and then to get the same sort of data that Instruments would give you.

Shame you have to build for 3.0. Almost nobody uses 3.x anymore, and ARC (while not a silver bullet for all issues) is way better than non-ARC.

Also here's a tip: delete the app from your simulator and reinstall it. I had an issue where some of my bundle resources were missing in my project but the Simulator was hanging onto them between builds. If you tried to load a .xib that is no longer in your project, I could see it crashing...

AlleyGator
  • 1,266
  • 9
  • 13