- Изменено
[cocos2d-x] Large memory allocations
I'm having large allocations from Spine runtime in Cocos2d-x. It keeps allocating until out of memory, then crashes.
I'm using GitHub's version (cloned 5 days ago, also having the problem with older version) I've found the allocations in this function:
spine::SkeletonBatch::nextFreeCommand()
Looking at the code, Spine allocates more memory when out of "commands slots".
What can cause to allocate more "commands slots"? My game is paused and the runtime keeps allocating more and more memory.
I just let the game running and eventually will crash. I'm not creating new skeletons, I preload all skeletons at load map, so there are always the same number of skeletons running.
Any idea or some guide to search where the problem could be?
Attach the stack call.
Thanks a lot.
EDIT: I think something is not being released when changing from scene because I can reproduce the problem now. Fails when going to main menu and start a second game. After this allocations ramp up considerably. I'm still digging into it.
EDIT 2: I've solved the problem destroying instance of SkeletonBatch (SkeletonBatch::getInstance()->destroyInstance()), so I think there is something there not being deallocated. Any idea?
Can you modify our cocos2d-x example in the runtimes repository to reproduce the issue? I tried to, but didn't see any issues with allocations.
I'm on deadline. By now, using the workaround mentioned in Edit 2 does the trick for me. I'll try to find some time to test if I can reproduce on the sample project.
Thanks.
The assumption is that you'll only ever have one SkeletonBatch throughout the entire life cycle of your application. I assume you are doing a mixed app with cocos2d-x views and native iOS views?