Jump to content

Remove texture from memory.


Recommended Posts

Hi again!


What would be the best way to remove unused textures from memory?


I put all textures in the array and when I dont need them anymore I call dispose() on each.
But this doesnt seem to work as expected and soon I get:

Not enough storage is available to complete this operation

on IE console while creating next textures I need.


Thanks for any help with that.




Link to comment
Share on other sites

Hi viktov. Has far has i know. Dispose(), so something similar has the delete() (javascript). This function cut's the objects reference to the memory (so you cannot access it anymore since it just lost it's pointer). This doesn't mean that memory will get free imediatly. Although it does something. When garbage collector comes to clean up the memory it will take all this to trash (since there's no way to reference it).


By saying this. I have to tell you.... I personally don't like very much the garbage collector. I prefer the good old times of ansi C, you could clean the memory directly :).


Is your specific case, the best way to solve your problem is by assigning to that array a value of null, by that your saying that the information contained in the array is illegible to the garbage collector. Something like:

var newArray = new Array();


for (bla bla bla){




then when you don't needed it no more, you do:

newArray = null;


Hope I've been helpfull.

Link to comment
Share on other sites

Hmm depend from where the texture is from (cached in a filesystem/database or not).

I see a part of the code creating blob url but never releasing it (not sure it's related to your problem).


Anyway, dispose() method seems the way to go.



Never change the type of a variable :(

An array is released at the end of a function, if it's on a closure or global namespace and required to be free, I'ld use arr.length = 0 and re-use the array letter.

But I have to agree about the garbage collector, a pain to the ass (did you know that it freeze the main thread when cleaning up another thread ? One of the weirdest things of WebWorker).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...