I'm having some difficulties with a webapp that I'm writing at the moment. Basically what I'm doing is working with a large array of images, and then creating textures of these images to draw in a 3D scene.

This all works very well, but I'm facing some memory issues. (as in: the memory usage is enormous ) What I'm trying to do is delete (nullify) the image arrays, and continue to work with the textures after all is done. This works, I don't have any access to my image arrays left, but I can still use the textures. The problem is that the memory usage isn't any lower.

My question: is it possible to delete the image array and keep the textures and free the memory of the images. Or is there still a reference from the textures to the image src and does this prevent it from freeing memory?.

My Second question if the deletion is not possible: Is copyTexImage2D a useful option to consider? I presume that if I create a copy of the texture through the framebuffer, it won't have any references left to the image array and the garbage collector will free up the memory?