Results 1 to 2 of 2

Thread: Freeing loaded texture

  1. #1

    Freeing loaded texture

    I am looking at the Textured Box demo on It has the following code snippets:
    Code :
    function loadImageTexture(ctx, url)
        var texture = ctx.createTexture(); // allocate texture
        texture.image = new Image();
        texture.image.onload = function() { doLoadImageTexture(ctx, texture.image, texture) }
        texture.image.src = url;
        return texture;
    function doLoadImageTexture(ctx, image, texture)
        ctx.bindTexture(ctx.TEXTURE_2D, texture);
        ctx.texImage2D(ctx.TEXTURE_2D, 0, ctx.RGBA, ctx.RGBA, ctx.UNSIGNED_BYTE, image);  // loaded the image
    var spiritTexture = loadImageTexture(gl, "resources/spirit.jpg");
    How do you free allocated/loaded texture in order to avoid memory leak?

    Will the following code free both the loaded/allocated texture and image?
    Code :
    spiritTexture  = null;
    Thanks in advance for your help.

  2. #2

    Re: Freeing loaded texture ... e-on-webgl answers my question.
    Code :

Similar Threads

  1. Is there maximum amount of loaded kernels?
    By Kallex in forum OpenCL
    Replies: 2
    Last Post: 07-28-2011, 12:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean