I just resolve MY PROBLEM which leads to this same assertion (“Node still marked as running on node destruction! Was base class onExit()…”), and I wanted here to post my contribution in case where somebody did the same mistake as me… Because YES, I made a small mistake, but it caused a very BIG and hard to resolve problem ! Let me explain
Somewhere in my code I did this mistake : I created a cocos2d-x object with a classic static create method, and then, since finally I did not need it, I delete it : like that
Button* but = Button::create(frame, "", "", TextureResType::PLIST);
if (_currentLine == nullptr ||
_currentLine->canAdd(but, _selectionBorderSize) == false)
if (addLine(but->getContentSize()) == false)
delete but; // HERE IS MY MISTAKE !!!!!
The result of that is that the memory zone occupied by my but pointer is freed, OK… But the problem is that the pointer is still in the AutoreleasePool _managedObjectArray list (the list of objects the cocos2d-x library internally evaluate periodically to see what must be auto-released because no longer used).
But it does not explain why it causes the assertion we talk about… In fact, later in my code, I create many other ui::Button and it is very strange but one of them takes exactly the same adress then the previous one ! So it is added 2 times in the AutoreleasePool list ! As a result, when auto-release is done by the AutoreleasePool instance of cocos2d-x application, this pointer is released 2 times and since I used the second button in my application, it is still added in its parent when the release is done the second time… And so, _running boolean is still true, causing the assertion
Arrrrrrrrg ! that was very difficult to debug… I was oblized to add code in the AutoreleasePool implementation to see that my pointer was 2 times in the list !
I hope this will help somebody since I spent one day on that “simple” problem
See yaa my friends