Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
How I unload a texture? — Gideros Forum

How I unload a texture?

edited August 2013 in General questions
My code is this:

function system.Unload()
print(application:getTextureMemoryUsage());
collectgarbage("collect");
collectgarbage("collect");
print(application:getTextureMemoryUsage());
logoWav = nil;
logoBmp = nil;
logoTexture = nil;
collectgarbage("collect");
collectgarbage("collect");
collectgarbage("collect");
collectgarbage("collect");
collectgarbage("collect");
collectgarbage("collect");
collectgarbage("collect");
collectgarbage("collect");
collectgarbage("collect");
collectgarbage("collect");
collectgarbage("collect");
print(application:getTextureMemoryUsage());
end


And the result is:

8192
8192
8192

How I force the unload of a texture?
I make games for children: http://www.kidoteca.com

Comments

  • @speeder_kidoteca
    Are you sure the variables you are nilling are available in the scope of the Unload function?
    Here is a quick test:
    print(application:getTextureMemoryUsage());
    local bg = Texture.new("bg.jpg")
    print(application:getTextureMemoryUsage());
    collectgarbage("collect");
    collectgarbage("collect");
    print(application:getTextureMemoryUsage());
    bg = nil
    collectgarbage("collect");
    collectgarbage("collect");
    collectgarbage("collect");
    collectgarbage("collect");
    collectgarbage("collect");
    collectgarbage("collect");
    collectgarbage("collect");
    collectgarbage("collect");
    collectgarbage("collect");
    collectgarbage("collect");
    collectgarbage("collect");
    print(application:getTextureMemoryUsage());
    Which produces expected output:
    0
    8192
    8192
    0
  • By the way, I decided to move on to do something else, and noticed that it started working AFTER I load other stuff... weird.

    It must be GC issues.
    I make games for children: http://www.kidoteca.com
Sign In or Register to comment.