Hello, cocos developers!
I added 1000 Nodes that has Graphics in it.
testGraphics2(count = 1000) {
const parent = this.node.getChildByName(“PopupStage”);
for (let i = 0; i < count; i++) {
const shape = new Node();
parent.addChild(shape);
const g = shape.addComponent(Graphics);
console.log(${i+1}th line draw.
);
g.lineWidth = 2;
g.strokeColor = new Color(255, 0, 0);
g.moveTo(-800, -count / 2 + i);
g.lineTo(0, 0);
g.stroke();
}
}
And when press key ‘r’, I destroy all children.
export function gs_dg_remove_all_children() {
const children = global.gs_stage[gs_popup_stage].children;
console.log(gs_dg_remove_all_children(): delete ${children.length} children
);
for (let i = children.length - 1; i >= 0; i–) {
children[i].destroy();
}
}
The two functions are called, but destory() doesn’t free any memory.
How to free memory of node, spriteFrame, label etc?
That’s okay, Thank you very much.
Then android and ios will be fixed also, right?
Android and iOS have not been tested, if there is a problem will be resolved.
Cool, I will wait v3.8.2.
This function (node and label) also increase memory and can’t be free.
testText2(count = 1000) {
const parent = this.node.getChildByName(“PopupStage”);
for (let i = 0; i < count; i++) {
const node = new Node();
parent.addChild(node);
node.setPosition(new Vec3(-count / 2 + i, -count / 2 + i, 0));
const label = node.addComponent(Label);
label.string = “Test Text.”;
label.fontSize = 80;
label.color = new Color(255, 100, 0);
}
}
I hope you to test it and fix in v3.8.2
Thanks for your work!!
Now create v3.8.1 is released.
How can I merge your PR ?
When will v3.8.2 be released?
3.8.2 may be released in 2024.1 .
You could customize the engine to apply the patch.
Reference: Cocos Creator 3.8 Manual - Engine Customization Workflow