Type Function
Object TextureResource
Library graphics.*
Revision 2018.3238
See also graphics.releaseTextures()


The graphics.newTexture() API pre-loads a texture/image and prevents it from being disposed even when there is no display object using it. In order to release the TextureResource object and restore automatic management for the texture, you must release it by calling texture:releaseSelf().

Alternatively, in a wider scope, graphics.releaseTextures() can be used to release all texture objects sharing the same type parameter.


After texture:releaseSelf() is called, only the texture handle is released and becomes invalid. All display objects which are using the TextureResource will hold on to their handles. The TextureResource itself will only be disposed after there are no display objects using it.


local texture = graphics.newTexture( { type="image", filename="background.png" } )

-- If you no longer need the texture, release it to prevent memory leaks