Quick answer: Use Allocator.TempJob for NativeList passed into jobs and disposed within 4 frames. Use Allocator.Persistent for long-lived. Don’t use Allocator.Temp with jobs.

You allocate a NativeList with Temp, pass it to a job. Safety system throws “Allocator mismatch.” Temp is main-thread-only.

The Symptom

Job scheduling throws InvalidOperationException about allocator. Switching to TempJob makes it run.

The Fix

// Bad — Temp not valid for jobs
var list = new NativeList<float3>(Allocator.Temp);

// Good — TempJob lives up to 4 frames, jobs allowed
var list = new NativeList<float3>(256, Allocator.TempJob);

var job = new AccumulatorJob { writer = list.AsParallelWriter() };
var handle = job.Schedule(N, 64);
handle.Complete();

for (int i = 0; i < list.Length; i++) Process(list[i]);
list.Dispose();

TempJob: 4-frame max lifetime. Dispose before that. Persistent: lives forever, manual dispose at teardown.

ParallelWriter

For IJobParallelFor writing to a list, use list.AsParallelWriter(). Thread-safe append. Each thread writes to its own segment.

Verifying

Switch from Temp to TempJob; allocator mismatch goes away. Profile shows the job running parallel without lock contention.

“TempJob for jobs. Persistent for long-lived. Dispose explicit.”

Related Issues

For Allocator.Temp warning, see Temp warning. For data race, see data race.

Right allocator. Right lifetime. Job runs.