pixi.js
    Preparing search index...

    Class GCSystemAdvanced

    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.

    // Register a resource for GC
    gc.addResource(myResource, () => {
    // cleanup logic here
    myResource.unload();
    });

    // Touch the resource when used (resets idle timer)
    gc.touch(myResource);

    // Remove from GC tracking (e.g., on manual destroy)
    gc.removeResource(myResource);

    Implements

    Index

    Constructors

    • Creates a new GCSystem instance.

      Parameters

      • renderer: Renderer

        The renderer this garbage collection system works for

      Returns GCSystem

    Properties

    maxUnusedTime: number

    Maximum time in ms a resource can be unused before being garbage collected

    now: number

    Current timestamp used for age calculations

    defaultOptions: GCSystemOptions = ...

    Default options for the GCSystem

    Accessors

    • get enabled(): boolean

      Gets whether the garbage collection system is currently enabled.

      Returns boolean

      True if GC is enabled, false otherwise

    • set enabled(value: boolean): void

      Enables or disables the garbage collection system. When enabled, schedules periodic cleanup of resources. When disabled, cancels all scheduled cleanups.

      Parameters

      • value: boolean

      Returns void

    Methods

    • Registers a resource for garbage collection tracking.

      Parameters

      • resource: GCableEventEmitter

        The resource to track

      • type: "resource" | "renderable"

        The type of resource to track

      Returns void

    • Registers a hash-based resource collection for garbage collection tracking. Resources in the hash will be automatically tracked and cleaned up when unused.

      Parameters

      • context: any

        The object containing the hash property

      • hash: string

        The property name on context that holds the resource hash

      • type: "resource" | "renderable"

        The type of resources in the hash ('resource' or 'renderable')

      • priority: number = 0

        Processing priority (lower values are processed first)

      Returns void

    • Cleans up the garbage collection system. Disables GC and removes all tracked resources.

      Returns void

    • Initializes the garbage collection system with the provided options.

      Parameters

      Returns void

    • Removes a resource from garbage collection tracking. Call this when manually destroying a resource.

      Parameters

      • resource: GCable

        The resource to stop tracking

      Returns void

    • Performs garbage collection by cleaning up unused resources. Removes resources that haven't been used for longer than maxUnusedTime.

      Returns void