aajiwani / EasyNDK-for-cocos2dx

NDK is always a problem. Writing such a code that can become a breeze in connecting with other platforms is always a problem when working with cocos2dx. This repo is a step made forward to make this pain a simple step.
MIT License
171 stars 107 forks source link

memory leak #18

Open rvsemenov opened 9 years ago

rvsemenov commented 9 years ago
   in void NDKHelper::HandleMessage(json_t *methodName, json_t* methodParams)

  CCObject *dataToPass = NDKHelper::GetCCObjectFromJson(methodParams);
  //dataToPass retain count 1

  if (dataToPass != NULL)
          dataToPass->retain();
  //dataToPass retain count 2

        CCFiniteTimeAction* action = CCSequence::create(CCCallFuncND::create(target, sel, (void*)dataToPass), NULL);

        target->runAction(action);//without retain and release

  if (dataToPass != NULL)
          dataToPass->autorelease();
        //dataToPass retain count 2 autorelease_count 1

And When i get data in me method

   void  method(CCNode *sender, void *data){
   }

data have retain count 2 autorelease_count 1 Need remove one retain

jasonchin commented 8 years ago

I found this as well, seems like the fix is either changing the first retain to autorelease and delete the autorelease at the bottom, or to change the second autorelease to just release. Can anyone confirm?