Internal: JobTempAlloc has allocations that are more than the maximum lifespan of 4 frames old - this is not allowed and likely a leak
I receives this warning without specifying the location of the code, How do I locate the problem and fix it.
Internal: JobTempAlloc has allocations that are more than the maximum lifespan of 4 frames old - this is not allowed and likely a leak
I receives this warning without specifying the location of the code, How do I locate the problem and fix it.
You have a native collection that was created with Allocator.JobTempAlloc and was not disposed. Always ensure that these are disposed properly. I usually use this pattern:
// Could be any collections
NativeArray array = new(..., Allocator.JobTempAlloc);
// Job scheduling that uses the collection
MyJob job = new() {
array = array,
...
};
state.Dependency = job.ScheduleParallel(..., state.Dependency);
// Dispose the collection
state.Dependency = array.Dispose(state.Dependency);
You can also use the attribute DeallocateOnJobCompletion on your job but I prefer calling the Dispose() myself as it is more clear when is it disposed.
Thank you very much. Perfect solution to my problem