DeallocateOnJobCompletion and NativeQueue

Any word on when containers like NativeQueue can be deallocated in a job?

They already do in Unity 2019.3. Just pass in a dependency job Handle and get a new handle back.

NativeQueue<float> test = new NativeQueue<float>(Allocator.Persistent);
var disposeJobHandle = test.Dispose(prevJobHandle);
disposeJobHandle.Complete();
2 Likes

That applies to all their native containers.

Ah excellent, thanks for pointing this out. I had worked around this previously using a cleanup system, and had hoped the new code-gen WithDeallocateOnJobCompletion would work (it doesn’t).

1 Like