Search Unity

Question Queue ECB Writes For Next Simulation Tick?

Discussion in 'Entity Component System' started by tbg10101_, Jan 3, 2021.

  1. tbg10101_

    tbg10101_

    Joined:
    Mar 13, 2011
    Posts:
    192
    Hello,

    I have a simulation loop where a pre-sim ECB system runs then a collection of sim systems run.

    I recently added a system that attempts to use the pre-sim ECB to clear a dynamic buffer on a collection of entities using EntityCommandBuffer.ParallelWriter.SetBuffer(). My intent was to have the buffers be cleared before the next simulation tick without having to write a system that is scheduled before the pre-sim ECB system.

    This appears to work but Unity's memory management system is complaining:

    Code (text):
    1. Internal: deleting an allocation that is older than its permitted lifetime of 4 frames (age = 5)
    2. UnityEngine.StackTraceUtility:ExtractStackTrace ()
    3. Unity.Collections.Memory/Unmanaged/Array:Resize (void*,long,long,Unity.Collections.Allocator,long,int) (at Library/PackageCache/com.unity.collections@0.14.0-preview.16/Unity.Collections/Memory.cs:79)
    4. Unity.Collections.Memory/Unmanaged/Array:Resize<Unity.Entities.EntityCommandBufferData> (Unity.Entities.EntityCommandBufferData*,long,long,Unity.Collections.Allocator) (at Library/PackageCache/com.unity.collections@0.14.0-preview.16/Unity.Collections/Memory.cs:85)
    5. Unity.Collections.Memory/Unmanaged:Free<Unity.Entities.EntityCommandBufferData> (Unity.Entities.EntityCommandBufferData*,Unity.Collections.Allocator) (at Library/PackageCache/com.unity.collections@0.14.0-preview.16/Unity.Collections/Memory.cs:35)
    6. Unity.Entities.EntityCommandBuffer:Dispose () (at Library/PackageCache/com.unity.entities@0.16.0-preview.21/Unity.Entities/EntityCommandBuffer.cs:1041)
    7. Unity.Entities.EntityCommandBufferSystem:FlushPendingBuffers (bool) (at Library/PackageCache/com.unity.entities@0.16.0-preview.21/Unity.Entities/EntityCommandBufferSystem.cs:255)
    8. Unity.Entities.EntityCommandBufferSystem:OnUpdate () (at Library/PackageCache/com.unity.entities@0.16.0-preview.21/Unity.Entities/EntityCommandBufferSystem.cs:190)
    9. Unity.Entities.ComponentSystem:Update () (at Library/PackageCache/com.unity.entities@0.16.0-preview.21/Unity.Entities/ComponentSystem.cs:113)
    10. Software10101.DOTS.Systems.Groups.ListComponentSystemGroup:UpdateAllSystems () (at Library/PackageCache/com.10101software.dots.hybridsimulation@b54f28834f/Runtime/Scripts/Systems/Groups/ListComponentSystemGroup.cs:113)
    11. Software10101.DOTS.Systems.Groups.ListComponentSystemGroup:OnUpdate () (at Library/PackageCache/com.10101software.dots.hybridsimulation@b54f28834f/Runtime/Scripts/Systems/Groups/ListComponentSystemGroup.cs:99)
    12. Unity.Entities.ComponentSystem:Update () (at Library/PackageCache/com.unity.entities@0.16.0-preview.21/Unity.Entities/ComponentSystem.cs:113)
    13. Unity.Entities.ScriptBehaviourUpdateOrder/DummyDelegateWrapper:TriggerUpdate () (at Library/PackageCache/com.unity.entities@0.16.0-preview.21/Unity.Entities/ScriptBehaviourUpdateOrder.cs:333)
    Is this a Unity bug or am I just handing something incorrectly?