• Runtimes
  • Extending SpineGameObject causes memory leak

I'm using Phaser 3.87, and esotericsoftware/spine-phaser: 4.2.71
if i do this, extending SpineGameObject, and writing methods and other data i need within it (i deleted all code except the one showed here, issue persists)
let symbol = new SpineSymbol({
scene: this.scene,
x: x,
y: y,
})
export class SpineSymbol extends SpineGameObject {
constructor({
scene,
x,
y,
} = {}) {
super(scene, scene.spine, x,y,'symbolsAnimationData','symbolsAnimationAtlas')
scene.add.existing(this)
}

it causes memory leak, but if i add symbols normally, like this,
this.scene.add.spine(x,y,'symbolsAnimationData','symbolsAnimationAtlas')
there is no memory leak, did i make a mistake somewhere to cause this memory leak?

Related Discussions
...

The memory leak you are experiencing when extending SpineGameObject in Phaser could be due to how the object is being managed or cleaned up. When you extend SpineGameObject and add it to the scene, ensure that you are properly managing its lifecycle, including removing it from the scene and freeing any resources it uses when it is no longer needed. The difference in behavior between using scene.add.spine directly and your custom class might be due to additional references or resources not being released in your custom implementation. Double-check that all resources, such as textures or animations, are properly disposed of when the object is destroyed.

    Spinebot Current issue I am experiencing occurs when scene is afk, i'm just adding spine object, and doing nothing else with the scene, i just leave it afk, and it still causes memory leak, not setting animation, changing scenes, or performing anything

    Actually the issue is much simpler than that, memory leak is caused by adding SpineGameObject to the container, i was able to replicate this, 100% of time by just doing this:
    let symbol1 = this.scene.add.spine(0,0,'symbolsAnimationData','symbolsAnimationAtlas')
    let container = this.scene.add.container()
    container.add(symbol1)

    on intervals of like 10/15 seconds, memory of the game continously increases, until browser crashes overtime, the more spinegameobjects we have in the container, it leaks faster. It happens on every game we worked on so far.

    Hello 🙂

    I am sorry, but I cannot reproduce the issue with our assets.
    Please, send us a minimal reproduction project here or by email at contact@esotericsoftware.com.
    It shouldn't be hard for you since you said you are able to reproduce it 100% of the time.

    We'll be happy to assist you, if we can reproduce the issue you are mentioning.