I can't delete Arrays from destroyed scene

I have 2 scenes in my project.
I load the second scene additive in to first all is good.
But when i have an array in my second scene i cant delete it although i destroy all the entitys from second scene.
I understand why it happens but i have no solution yet.

How can i delete all arrays when i loading the scene additive again?

Answered on Discord:

https://playcanvas.com/editor/code/875929?tabs=66931660

var CreateCube = pc.createScript('createCube');
CreateCube.attributes.add("cube", { type: "entity" });
//CreateCube.attributes.add("cubeGRP", { type: "entity" });
// initialize code called once per entity
CreateCube.prototype.initialize = function () {

    this.cubes = [];
    for (let i = 0; i < 10; i++) {
        let cube = this.cube.clone();
        cube.enabled = true;
        this.cubes.push(cube);
        //this.cubeGRP.addChild(cube);
    }

    this.on('destroy', function() {
        for (let i = 0; i < this.cubes.length; i++) {
            this.cubes[i].destroy();
        }

        this.cubes = null;
    }, this);
};

Fork: https://playcanvas.com/editor/scene/1323394

It does feel wrong here that the cubes isn’t part of the scene hierarchy as technically it shouldn’t be rendering (edited)

That might cause issues down the line

CreateCube.prototype.initialize = function () {

    this.cubes = [];
    for (let i = 0; i < 10; i++) {
        let cube = this.cube.clone();
        cube.enabled = true;
        this.cubes.push(cube);
        this.cubeGRP.addChild(cube);
    }
}

For this particular project, this is better