function foo(){
function createnode(parentnode){
let node = new ccnode();
parentnode.add(node);
}
settimeout(function(){
foo()
}.bind(this), 100);
}
dose this code phrase cause memory leak? I’ll clean the parent node at sometime with parentnode.destroyAllchildren(), but when my application run on ios device with Xcode instrument, which told me lots of memory leak, althrough every leak is about 197 bytes less, but lots of them
Yes, buddy, thanks a lot, I know this way to release the function though I don’t put the release code in this phrase, my question is , in this recursive way, dose this node can be destroyed, cause Xcode instrument said that my application have lots of memory leak. I’m not quiet specific where about
This is because you are creating an anonymous function and it will be kept in memory.
So, it’s better to create it as a method of an object or extend an existing class thru prototype.