Memory efficient javascript

Out of context: Reply #6

  • Started
  • Last post
  • 9 Responses
  • monNom0

    ^ a huge sprite sheet is probably going to be more trouble than individual files unless we're talking a clock or something smaller.

    I'd suggest something like

    var myImage = new Image()
    myImage.src = 'url';
    // do things with the image, either append to DOM or draw to canvas
    //when done with it
    delete myImage();

    that should free up the memory used by the image when the garbage collector comes around.

    otherwise, your only problem might be a long running loop, but my link above gives strategies for that.

    • delete statement should read

      delete myImage;
      monNom

View thread