I'm looking for advice about the cleanup component pattern when cleaning up components that reference a native container that should be disposed.
Let's say we have
public struct ContainerComponent : IComponentData {
public NativeList<int> container;
}
The docs (https://docs.unity3d.com/Packages/com.unity.entities@1.0/manual/components-cleanup-create.html) seem to suggest that another component that inherits ICleanupComponentData should be created. Though, to perform the cleanup, the other component should then also reference the container?
If that is the case then reallocating the container becomes cumbersome, also if the entity is destroyed before this cleanup component is created then we are leaking some memory.
Therefore I am thinking that ContainerComponent should directly inherit ICleanupComponentData, but then a tag component such as AliveContainerComponent becomes necessary for the cleanup system to differentiate alive/to-cleanup entities?
