0

Possible Duplicate:
Xcode malloc error

My game crashed sometimes due to this message:

malloc: *** error for object 0x65cfcd4: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug

So as advised, I ran the Allocations tool in instruments to try find the leak and tecked Enable NSZombie Detection. It said it was checking for zombies during execution.

But the app crashes and NOTHING is caught.

Any reason why a zombie wouldn't catch it?

Thanks.

Community
  • 1
  • 1
FBryant87
  • 4,273
  • 2
  • 44
  • 72
  • It seems as though the memory of the object that you want to release is overwritten by something else. You can't fix this with the Zombies - the object is still there, it's just that something else messed with it. Doing any fancy pointer stuff? C-Arrays without bounds checking? Casting? – w-m Aug 27 '11 at 15:18

2 Answers2

2

The advise isn't to enable zombies, zombies are Objective-C only and malloc, realloc and free are the C way of allocating memory, the zombie tool won't catch these errors. Set a breakpoint in malloc_error_break and look at the stack trace to resolve the error.

JustSid
  • 25,168
  • 7
  • 79
  • 97
0

Without getting too fancy, you can remove all your free calls and see if it fixes the problem. If your project isn't very large scale, this may be faster than any "professional tool" you will use. If it fixes the issue, just plug the free calls one by one and the answer should become apparent.

If you use cocos2d, simply delete all those "Free" calls. C memory allocation is easy to get wrong.

kizzx2
  • 18,775
  • 14
  • 76
  • 83
  • I am using cocos2d, sorry do you mean just remove all the release's? it's pretty big... – FBryant87 Aug 27 '11 at 15:26
  • Hold on, you want him to leak memory (possible A LOT of memory) on a device which has no memory swapping and a fairly limited amount of physical memory?! – JustSid Aug 27 '11 at 18:56
  • @JustSid He's probably running in the simulator. If it actually helps him find the issue, who cares if we break the free memory dogma temporarily? (It's not like leaking memory is more acceptable in desktop applications for any worthwhile project is acceptable anyway.) – kizzx2 Aug 28 '11 at 00:07