AdvancedMaximum time in ms a resource can be unused before being garbage collected
Current timestamp used for age calculations
StaticdefaultDefault options for the GCSystem
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.
Registers a resource for garbage collection tracking.
The resource to track
The type of resource to track
Registers a hash-based resource collection for garbage collection tracking. Resources in the hash will be automatically tracked and cleaned up when unused.
The object containing the hash property
The property name on context that holds the resource hash
The type of resources in the hash ('resource' or 'renderable')
Processing priority (lower values are processed first)
Cleans up the garbage collection system. Disables GC and removes all tracked resources.
Initializes the garbage collection system with the provided options.
Configuration options
Removes a resource from garbage collection tracking. Call this when manually destroying a resource.
The resource to stop tracking
Performs garbage collection by cleaning up unused resources. Removes resources that haven't been used for longer than maxUnusedTime.
A unified garbage collection system for managing GPU resources. Resources register themselves with a cleanup callback and are automatically cleaned up when they haven't been used for a specified amount of time.
Example