Advanced
Creates a new RenderableGCSystem instance.
The renderer this garbage collection system works for
Maximum time in ms a resource can be unused before being garbage collected
Static
defaultDefault configuration options for the garbage collection system. These can be overridden when initializing the renderer.
Gets whether the garbage collection system is currently enabled.
True if GC is enabled, false otherwise
Enables or disables the garbage collection system. When enabled, schedules periodic cleanup of resources. When disabled, cancels all scheduled cleanups.
Adds an array to be managed by the garbage collector.
The object containing the array
The property name of the array
Adds a hash table to be managed by the garbage collector.
The object containing the hash table
The property name of the hash table
Starts tracking a renderable for garbage collection.
The renderable to track
Cleans up the garbage collection system. Disables GC and removes all tracked resources.
Initializes the garbage collection system with the provided options.
Configuration options for the renderer
Updates the GC timestamp and tracking before rendering.
The render options
The options for rendering a view.
Optional
clear?: CLEAR_OR_BOOLThe clear mode to use.
Optional
clearColor?: ColorSourceThe color to clear with.
The container to render.
Optional
target?: RenderSurfaceThe render target to render. if this target is a canvas and you are using the WebGL renderer,
please ensure you have set multiView
to true
on renderer.
Optional
transform?: Matrixthe transform to apply to the container.
Performs garbage collection by cleaning up unused renderables. Removes renderables that haven't been used for longer than maxUnusedTime.
The RenderableGCSystem is responsible for cleaning up GPU resources that are no longer being used.
When rendering objects like sprites, text, etc - GPU resources are created and managed by the renderer. If these objects are no longer needed but not properly destroyed (via sprite.destroy()), their GPU resources would normally leak. This system prevents that by automatically cleaning up unused GPU resources.
Key features:
Best practices:
Example