giniedp / spritespin

jQuery plugin for spriteanimation.
http://giniedp.github.com/spritespin/
MIT License
377 stars 122 forks source link

Memory Leaks Chrome? #92

Open Geddo opened 1 year ago

Geddo commented 1 year ago

First: Awesome tool. Super useful and well documentated. Keep up the good work.

My current problem: After creating and destroying multiple spritespins, I have many "Detached HTMLImageElements" which are not getting garbage collected

Example ("spritespin": "@beta"):

let spriteSpinInstance = null;
let images = null;
let frames = null;
window.getSpriteSpinInstances = function () {
  return spriteSpinInstance;
};
export function initTurntable() {

    images = $("#turntable").attr("data-images");

    frames = SpriteSpin.source(images, 
        {frame: [1, 719], digits: 3});

    spriteSpinInstance  = SpriteSpin.create({
      target: '#turntable',
      source: frames,
      width: 2160,
      height: 2160,
      animate: false,
      detectSubsampling: false,
      frames: 719,
      retainAnimate: false,
      sense: -1,
      plugins: [
          'drag',
          'ease',
          '360'
      ]     
    })
}
export function destroyTurntable() {  
    if($("#turntable").lenth) {     
      SpriteSpin.destroy("#turntable");   
    }
    if (spriteSpinInstance !== null) {        
        spriteSpinInstance.destroy();     
    }
    spriteSpinInstance = null;
}

After destroyTurntable I also remove the div where the turntable was set. Besides the "Detached HTMLImageElements" I also have many Arrays and Object leftovers from previews turntables so it seems that "destroy" not really removing all Eventhandlers and stuff from the turntables.

Am I missing something?