• Runtimes
  • [Cocos2d-x]Help, app crashing after using spine animations

Hello,

I am making a children book app using Cocos2d-x and objective-c. I am adding some simple animations to each book page, and myself and my programmer are experiencing some major crashing. It seems it might be related to the buffer memory. Some how, it looks like as we advance pages we keep having all the animations on buffer memory.

Is there any way to release the “SkeletonAnimation” and “spSkeletonData” objects?

We are facing a memory Error after we started using spine animations. This is the error we get:
The app "book1" on "working's ipad" quit unexpectedly. Message from debugger: Terminated due to memory error.

When this issue happens no log message is displayed in debug area.

Thank you,

Ivan

Related Discussions
...

Well, you can replace the memory allocators in spine to do some memory tracking.

    // Register our malloc and free functions to track memory leaks
#ifdef _DEBUG
    _setDebugMalloc(_kanjimalloc);
#endif
   _setMalloc(_kanjimalloc);
    _setFree(_kanjifree);

// My debug allocator:
//Replacement for the standard malloc/free, records size of allocation and the file/line number it was on
inline void* _kanjimalloc (size_t size, const char* file, int line)
{
    void* ptr = (void*)malloc(size);
    KMemoryAddTrack(ptr, size, file, line); // This is a dictionary/map of [ptr]->record; the entry is removed on _free(ptr)
    return(ptr);
}

Or, You can use XCode's memory profiling tools: http://www.cocos2d-x.org/wiki/How_to_Op ... mory_Usage

The XCode profiling tools are very good once you get the hang of them.

18 gün sonra

thank you very much James,

We still haven't solved the problem yet, but still working on it. Your post is very helpful.


Unfortunately we are still struggling with the project after adding some spine animations. I'm sure we are making something stupid, or missing something key but after a while, the app crashes.

It is definitively a memory issue and not being able to handle the animations properly. It seems that they piled up and neither release nor stop, therefore creating a memory issue. I am using clearTrack(); something like "clearAnimation" that I see it is explained in the documentation. It works but it clears the animation permanently which we do not want. So how can I release, remove or STOP animation run SkeletonAnimation Object in run time by pressing a button or under any callback timely?.

i am using this code snippet to run an animation
SkeletonAnimation *kidNode = SkeletonAnimation::createWithData(kidData);
kidNode->setAnimation(2, "animation", false);


            kidNode->setPosition(pos);
            addChild(kidNode,2);

Let's say there is a leaf animation that is looping. I want to press a button or callback a method which will stop the leaf animation instantly and there is no further movement of leaf, realease from memory but that will play again in loop mode if we call it again.

Thank you,

createWithData allocates. It loads all the Spine data. Use spSkeletonJson to load the data once, then use that to create SkeletonAnimations. Otherwise, if there is a memory leak, we'll need more info on where.