0

This may sound like a noob question, because it is. I have tried for days to figure out what I am doing to make it crash, but I can't figure it out.

I have various objects that use CCActions. When the objects need to be removed from screen, I call [spriteObject stopAllActions]; I then release the actions. (I retain the actions in init, as I was trying to avoid this kind of crash).

The program randomly crashes at this line in CCScheduler:

[elt->currentTimer release];

The error message is that I am sending a message to a deallocated instance. But I can't figure out what gets deallocated when. I retain all the actions I create. I even tried running the program without ever releasing the actions, to see If that was the cause, but it still crashes.

Sometimes it crashes after 20minutes, sometimes after 2 minutes. It is pretty random. I'm not sure what to put up because the code is pretty spread out.

Basically, I have a Sprite, which contains a "Strategy" object, which contains the CCAction that is running. At run time I create a "strategy" and pass it to the sprite which retains the strategy.

The sprites are not deallocated until the end of program execution.

Any ideas on how I can figure out what is being deallocated, where and why? I really can't figure it out. Not sure what information to put up here. :C

4
  • Please post more codes in order to locate the error. But apparently, the timer is already released before you call release
    – Raptor
    Mar 13, 2012 at 9:59
  • You can check retain count to see if that is the problem. Mar 13, 2012 at 12:50
  • It seems that cocos2d is not expected to be thread safe, so the api shouldn't be accessed from multiple threads. I guess I need to make a design change.
    – Rahul Iyer
    Mar 13, 2012 at 14:13
  • don't retain actions, don't manually release them either. Sending stopAllActions is enough. If the node running the action gets removed from the node hierarchy, you don't need to manually stop/remove the actions at all.
    – CodeSmile
    Mar 14, 2012 at 11:55

1 Answer 1

0

Cocos2d is currently not thread safe, and the api's are not expected to be called from other threads.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.