Having to garbage collect to keep ios from crashing

I can reliably reproduce this issue which has cost me a day of debugging and verifying.

what happens is a child node fires an eventCustom event bubbling up to here and display results eventually changes the scene. Then the memory from that is held and increases until ios crashes the app.

Now if I place the code outside the run action the memory does increase but clearCachedData actually does clear it and all is normal again.

this.node.on(EVENT.DONE, (evnt) => {
        
        this.selectors.node.runAction(cc.sequence(
            cc.fadeOut(0.3),
            cc.callFunc(() => {
                this.selectors.node.x = 5000;
              // this.displayResults(); // this causes a memory leak!
            })
        ));

Now I am happy to be wrong if this is a bad practice.

[EDIT]

I’m finding I’m having to run

onDestroy: function() {
  cc.sys.garbageCollect();
},

everywhere to keep ios from crashing on the iphone 6 (10.2.1), is this normal?

Have you gone through this thread?

There are some things to look out for when using creator, especially when you do release resources.
Also, make sure your scene is set to auto release assets in the property panel

thats my own thread and yes I have autoreleasing turned on. I’ve also got all dynamic assets being added to the autorelease pool.

Well, yea, that’s what I’m doing too. I schedule a garbage collect call everytime i release dynamic loaded assets. I don’t do it too frequently as it causes hiccups whenever it is called. I think the best point of calling this is when you’ve destroyed all the nodes built from the assets, and released the assets. Seems strange to me that we need to explicitly call the garbage collector

Although I am facing an issue, am not sure if it’s on my end or on the loader, still checking out on it, if it runs long enough, sometimes, not all of the memory is released whenever cc.loader.released is called. The getdeps function sometimes only return an array with just one uuid, instead of an array filled with paths to the assets.