CombineDependencies(NativeArray) behavior

Couldn’t find this documented anywhere, so…

Is it necessary to keep the NativeArray around after passing it to CombineDependencies(nativeArray)? Can I call Dispose() on the array right after combining all the job handles into a single one?

I mean, will this explode in some way?:

NativeArray<JobHandle> deps = new NativeArray<JobHandle>(5 ,Allocator.TempJob, NativeArrayOptions.UninitializedMemory);
// fill the array with handles here
JobHandle combined = JobHandle.CombineDependencies(deps);
deps.Dispose();
// use combined JobHandle here

You can dispose the array after the call, it’s safe.

3 Likes

Why make it Allocator.TempJob then? Is it safe to use Allocator.Temp given its lifespan?

Both are safe options. You can use Allocator.Temp as well.