In my DOTS project, I am getting this error:
Internal: JobTempAlloc has allocations that are more than 4 frames old - this is not allowed and likely a leak
whenever I run my DOTS based scripts. The project is an editor tool so I am running it in the editor.
I am not using Allocator.TempJob
anywhere in the scripts that cause this error. I’m only using Allocator.Persistent
and then disposing those arrays after all the jobs complete and using Allocator.Temp
for arrays allocated and disposed of within jobs. I already tried changing all the Allocator.Temp
’s to Persistents
and that didn’t help. I am scheduling Jobs
with dependencies to each other and then checking for when they complete every frame using EditorApplication.update
. This way they run in the background and don’t halt the main thread. When the work is relatively small, I don’t get the error, but when I give the tool a bigger task to complete I get this error message.
I also noticed that when I schedule the jobs and then immediately call jobHandle.Complete() I get no warning no matter how large the jobs are. The warning only comes when I call schedule and then check jobHandle.IsCompleted every frame and then call jobHandle.Complete() when that returns true.
I am using UnsafeList in these jobs as well. I am doing so so that I can have arrays of arrays in jobs. I do this by using NativeArray>.
_
Does Unity perhaps create jobs behind the scenes that use TempJob
allocators in order to schedule jobs or copy NativeArrays
or combine JobHandles
or anything like that? If so then I could try to identify what’s too big for Unity’s behind the scenes job and split it up into smaller chunks.
_
I can try to create a project with the error reproducible if anyone wants to take a look. I am using Unity 2019.4.10f1 for this project.