Search code examples
ipadios4memory-leaks

ipad app crashes on new iOS 4.1.2 but works on 3.2


I have a app in which i play a splash video and have added some custom fonts.

The app works fine on ipad 3.2 but on 4.2 etc it crashes. The log says that i release something that i dint alloc. I have checked my code a hundred times and i dont do any such thing.

Either ways it works on the simulator and on the device(both 3.2)

any ideas?

EDIT:

<Error>: df(7903,0x3e3d7898) malloc: *** error for object 0x1a11b0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Wed Jan 19 20:35:38 unknown UIKitApplication:com..imagazine[0x9c7c][7903]                         <Notice>: def(7903,0x3e3d7898) malloc: *** error for object 0x1a11b0: pointer being           freed was not allocated
 Wed Jan 19 20:35:38 unknown UIKitApplication:com.imagazine[0x9c7c][7903] <Notice>: *** set a breakpoint in malloc_error_break to debug
   Wed Jan 19 20:35:39 unknown ReportCrash[7905] <Notice>: Formulating crash report for process df[7903]
  Wed Jan 19 20:35:39 unknown com.apple.launchd[1] <Warning>: (UIKitApplication:com.imagazine[0x9c7c]) Job appears to have crashed: Abort trap
  Wed Jan 19 20:35:39 unknown SpringBoard[27] <Warning>: Application 'df' exited abnormally with signal 6: Abort trap
  Wed Jan 19 20:35:39 unknown ReportCrash[7905] <Error>: Saved crashreport to /var/mobile/Library/Logs/CrashReporter/df_2011-01-19-203538_Sumas-iPad.plist using uid: 0 gid: 0, synthetic_euid: 501 egid: 0

SOLUTION:

First of all use the NSZombies and you will catch such errors.

The Problem: I had a timer setup for every 0.2sec and it was clearing a UIView and allocating it, not every 0.2secs but maybe once every 5secs. I did a standard check:

  if(vewCustom!= nil) {
      [vewCustom removeFromSuperView];
      [vewCustom release];
      vewCustom = nil;
   }

But the strange thing was i verified the code hundreds of times and I was not over releasing and either ways it worked on iOS4.2 for iPhone.

I removed the Timer but still it was crashing and then I removed the release and now it works fine.

Strange but it would be good if someone can explain what i was doing wrong.


Solution

  • You could try running the app in debug with zombies enabled. This way you'll get a stack trace on the overreleased object here's a link on how to set it up.

    http://iosdevelopertips.com/debugging/tracking-down-exc_bad_access-errors-with-nszombieenabled.html