Parallel TempJob not being disposed on the same frame

Abner Santos

New member
Hey there! Been enjoying the package, thank you

However, we've been having issues with the Parallel task. We believe since it does not dispose it's TempJob allocation on the same frame, it's giving us this warning:
Screenshot 2026-01-22 at 16.54.59.png

We've used Unity's diagnostics to pinpoint that it comes from the EntityCommandBuffer allocation in the ParallelTaskSystem

2026-01-22_16-59.png

We saw that instead of disposing the entity command buffer in the same frame you dispose it at the start of the next frame, here:

C#:
        private void OnUpdate(ref SystemState state)
        {
            m_Dependency.Complete();
            if (m_EntityCommandBuffer.IsCreated) {
                m_EntityCommandBuffer.Playback(state.EntityManager);
                m_EntityCommandBuffer.Dispose();
            }

            m_EntityCommandBuffer = new EntityCommandBuffer(Allocator.TempJob);
            state.Dependency = new ParallelJob()
            {
                EntityCommandBuffer = m_EntityCommandBuffer.AsParallelWriter()
            }.ScheduleParallel(m_Query, state.Dependency);
            m_Dependency = state.Dependency;
        }

We believe that's the issue. Is there a reason for that? Would it be possible to dispose it at the end of the frame instead? Like this:

C#:
        private void OnUpdate(ref SystemState state)
        {
            m_Dependency.Complete();
            
            EntityCommandBuffer ecb = SystemAPI.GetSingleton<EndSimulationEntityCommandBufferSystem.Singleton>()
                .CreateCommandBuffer(state.WorldUnmanaged);
            state.Dependency = new ParallelJob()
            {
                EntityCommandBuffer = ecb.AsParallelWriter()
            }.ScheduleParallel(m_Query, state.Dependency);
            
            m_Dependency = state.Dependency;
        }

My guess is since our server's tick rate is low and the BTs only run on the server world, that is leading to that warning being spammed every frame since it's being disposed only on the next server tick

Thank you in advance!
 
Thanks for the details. A server with a low tick rate is a case that I didn't consider for this. Your change looks good, I'll run it through my unit tests and get back to you if anything pops up but I don't expect it to. I'll then include it in the next release.
 
Back
Top