Skip to content

RenderSystemBase.Dispose(bool) Method

Definition

Namespace: Brine2D.ECS.Systems

Override to release cached queries and other resources held by this system. Always call base.Dispose(disposing).

C#
protected virtual void Dispose(bool disposing);

Parameters

disposing System.Boolean

Remarks

Any CachedEntityQuery<T1> \(or higher\-arity sibling\) created via CreateCachedQuery<T1>() must be disposed here. Failing to do so leaves the query registered in the world's invalidation index, preventing GC until the world itself is disposed.

C#
private CachedEntityQuery<TransformComponent>? _query;

public override void OnStart(IEntityWorld world)
    => _query = world.CreateCachedQuery<TransformComponent>().Build();

protected override void Dispose(bool disposing)
{
    if (disposing) _query?.Dispose();
    base.Dispose(disposing);
}