void Dispose()

book_4_sparkGenerated
code_blocksInput

Description

The Dispose method is used to release the handle for a texture in the Sandbox engine. This method is particularly useful for freeing up resources immediately when you are done with a texture, rather than waiting for the garbage collector to automatically release it. This can be beneficial in scenarios where you want to manage memory usage more precisely, especially in performance-critical applications.

When you call Dispose, if the texture is not referenced by any other objects, it will be released properly. This method is automatically called in the destructor, so it is not strictly necessary to call it manually unless you need to release the texture immediately.

Usage

To use the Dispose method, simply call it on an instance of a Texture object when you are finished using it. This will ensure that the resources associated with the texture are released promptly.

Example usage:

Texture myTexture = Texture.Load("path/to/texture");
// Use the texture for rendering or other operations

// When done with the texture
myTexture.Dispose();

By calling Dispose, you are explicitly indicating to the engine that you are done with the texture, allowing it to free up resources immediately.

Example

Texture myTexture = Texture.Load("path/to/texture");
// Use the texture for rendering or other operations

// When done with the texture
myTexture.Dispose();