At some stage, I started getting a message in the editor about a memory leak that could impact performance, and the message advised me to run unity with -diag-job-temp-memory-leak-validation at the command line. I do this… now what? It advises me that diagnostic switches are now active, but I cant see anything telling me that it found an error, or how I should proceed from here. Ive searched google for the error message and similar phrases, but can’t find anything related at all. Can anyone kindly point me to the relevant docs? I’ve had a look at the memory profiler, but that’s way beyond me at this stage. Im hoping for the computer to kindly underline whatever is Im doing wrong, perhaps over-optimistically. Im not using any natural arrays or data types that Im aware need manual freeing of memory. So Im guessing there must be other ways to somehow stuff up memory with whatever I am doing.
Posted during holidays, so probably not great for visibility. Bump, anyone?
Hi @lordumbilical !
I’ve asked on internal slack if we have public docs for the feature.
Hi, Sadly we do not have public docs about it. Originally this feature was internal use only, mostly because it was asking to enable macro in C++ code. This was always problematic as it required recompiling unity after change and only people having source code could really do it.
This is where -diag-job-temp-memory-leak-validation come. When app is started with this command line argument (or in case of editor we just enable it in diagnostic switches) we swaps some of our allocators on heavier, debug versions. It collect additional informations like callstack and log leaked memory whenever issue occurs to console or log file.
Could you also share version of Unity that you are using? In past, while doing some other changes we sadly introduce small issue to this system which in my knowledge should has been fixed, but I would double check it.
It’s 2022.2.1f1. The error message did only begin about the time I updated to this version. Would there be a guide to allocating memory properly? Maybe I am doing something wrong. The project is very simple, and I am just passing primitive data types, but maybe I am doing it wrong. I don’t know.
If you aren’t directly touching unmanaged code – NativeArrays, bursted jobs, etc. – this probably isn’t something you’re causing.
I see these warnings now and then in 2022.2.1f1 on my Silicon mac. I did turn on the diagnostic switch, and it is providing some more details about the leaked allocations. IIRC they’re somewhere in the graphics system – something about command buffers?
Ah, ok that’s good to know. So I will just ignore the issue if there is nothing I can do.
Just like @chemicalcrux I do not think this would be your fault and I suspect that there may be issue inside unity codebase. Could you guys share this additional details with us? I would look into it so we could resolve this issue.
I’m also experiencing this issue in both 2022.2.1f1 and 2022.2.0b12. In my case, it seems to be triggered by the third party Corgi Engine asset after import, which overrides a bunch of project settings and has Package Manager dependencies (not sure if this could cause the issue), hence why I didn’t post here. I can’t find anything in the Corgi forums about it either, though. Haven’t tested for this warning getting triggered by other assets.
When I start with a fresh project (2D URP) in 2022.2.1f1 and click on items in the Project window, no warnings appear. Then, I import Corgi Engine… Allow it to override Project Settings… It says some of its source files refer to API that has changed, asks if I want these files updated… I’ve tested with both saying yes and no, same end result.
After the asset is imported and I click on random items in both the Asset folder and Packages folder, Unity gives these warnings, also seemingly at random:
[Worker0] Internal: There are remaining Allocations on the JobTempAlloc. This is a leak, and will impact performance
[Worker0] To Debug, run app with -diag-job-temp-memory-leak-validation cmd line argument. This will output the callstacks of the leaked allocations.
[Worker1] Internal: There are remaining Allocations on the JobTempAlloc. This is a leak, and will impact performance
[Worker1] Internal: JobTempAlloc has allocations that are more than the maximum lifespan of 4 frames old - this is not allowed and likely a leak
I’m relatively new to Unity and this is way over my head, so I started a new project in 2021 LTS and haven’t received any of these warnings (as well as others I was getting in 2022 with Corgi and URP). Just wanted to relate my experience with them and how they seemed to be triggered by an asset.
I get the same error message, except the one mentioning “maximum lifespan of 4 frames”. Mine started about the same time i moved from default (2D) to the Universal Render Pipeline, but that’s just a guess. Please let me know what specific information you might want.
Have you turned on the diagnostic flag? It’ll spit stuff out into the logs (as info, not as warnings) when these warnings would otherwise be reported.
Check the user settings menu (not project settings) – it’s in the Diagnostics section.
I tried clicking on folders and assets in the Project window with JobTempMemoryLeakValidation turned on in 2022.2.1f1 and it started giving some new information in the console. This is what it logged when I randomly clicked on the Custom NUnit folder under Packages in the Project window (copied from Editor Log):
Warnings:
[Worker0] Number of updated assets reloaded before import = 0
[Worker0] Start importing Packages/com.unity.ext.nunit using Guid(25a477c2f24db8778a4179421a32cc21) Importer(815301076,1909f56bfc062723c751e8b465ee728b)
[Worker0] -> (artifact id: '084dec501e1f4c6611a6b594e6838766') in 0.004419 seconds
[Worker0] Internal: There are remaining Allocations on the JobTempAlloc. This is a leak, and will impact performance
[Worker0] To Debug, run app with -diag-job-temp-memory-leak-validation cmd line argument. This will output the callstacks of the leaked allocations.
Logs:
[Worker0] Allocation of 32 bytes at c001e920 in block 0 (frameIndex=4, lifetime=4, age=2, state=OK)
[Worker0] 00 00 00 00 00 00 00 00 60 1a 72 91 c2 01 00 00 ........`.r.....
[Worker0] 00 00 00 00 00 00 00 00 05 00 00 00 00 00 00 00 ................
[Worker0] 20 e9 01 c0 c3 01 00 00 60 1a 72 91 c2 01 00 00 .......`.r.....
[Worker0] 02 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 ................
Then I tried turning off JobTempMemoryLeakValidation and, after restarting, all the warning and logs stopped appearing. So I’m wondering if Unity had JobTempMemoryLeakValidation turned on by default before somehow? I even searched the Editor Log and couldn’t find any of the previous warnings.
So turning it on/off and restarting each time fixed the problem for me so far, thanks!
Shouldn’t that also be spiting out the callstack (the sequence of functions that were called to get you to a specific place)? That’s going to be the more useful bit of information: where the leaked memory was allocated.
It might be in a separate log message.
Nevermind, the memory leak warnings came back after a while. Sorry, I don’t know how to find the callstack and had trouble running the app with -diag-job-temp-memory-leak-validation in the cmd line argument… Here’s a section of the log if it helps, though:
.Worker ready: AssetImportWorker1 1
Worker ready: AssetImportWorker0 0
[Worker0] Number of updated assets reloaded before import = 0
[Worker0] Start importing Assets/CorgiEngine/Demos/Retro/Prefabs/PlayableCharacters/RetroCorgi.prefab using Guid(460a0ee26c86f4e5ab4b2678c9712069) Importer(815301076,1909f56bfc062723c751e8b465ee728b)
[Worker0] -> (artifact id: 'cab1bd7eaecdf23fb53fe09ecb27bd98') in 0.297716 seconds
[Worker0] Internal: There are remaining Allocations on the JobTempAlloc. This is a leak, and will impact performance
[Worker0] To Debug, run app with -diag-job-temp-memory-leak-validation cmd line argument. This will output the callstacks of the leaked allocations.
[Worker0] Allocation of 32 bytes at c0026a40 in block 0 (frameIndex=0, lifetime=4, age=1, state=OK)
0x00007ff709a2ef8b (Unity) PlayableGraph::smile:estroyPlayableDeferred
0x00007ff709e9bd91 (Unity) Animator::ClearInternalControllerPlayable
0x00007ff709e9bfa9 (Unity) Animator::ClearObject
0x00007ff709e9d02f (Unity) Animator::smile:eactivate
0x00007ff709401995 (Unity) GameObject::ActivateAwakeRecursivelyInternal
0x00007ff7094017d4 (Unity) GameObject::ActivateAwakeRecursivelyInternal
0x00007ff7094017d4 (Unity) GameObject::ActivateAwakeRecursivelyInternal
0x00007ff7094017d4 (Unity) GameObject::ActivateAwakeRecursivelyInternal
0x00007ff709401559 (Unity) GameObject::ActivateAwakeRecursively
0x00007ff7094044f9 (Unity) GameObject::smile:eactivate
0x00007ff7097ab030 (Unity) UnityScene::OnGameObjectChangedScene
0x00007ff7099b0c6d (Unity) SceneManagerBindings::MoveGameObjectToScene
0x00007ff708bd4071 (Unity) SceneManager_CUSTOM_MoveGameObjectToScene_Injected
0x000001d681424a15 (Mono JIT Code) (wrapper managed-to-native) UnityEngine.SceneManagement.SceneManager:MoveGameObjectToScene_Injected (UnityEngine.GameObject,UnityEngine.SceneManagement.Scene&)
0x000001d68142493b (Mono JIT Code) UnityEngine.SceneManagement.SceneManager:MoveGameObjectToScene (UnityEngine.GameObject,UnityEngine.SceneManagement.Scene)
0x000001d6814296e3 (Mono JIT Code) UnityEditor.PreviewScene:AddManagedGO (UnityEngine.GameObject)
0x000001d681429663 (Mono JIT Code) UnityEditor.PreviewRenderUtility:AddManagedGO (UnityEngine.GameObject)
0x000001d681426f23 (Mono JIT Code) UnityEditor.GameObjectInspector/PreviewData:UpdateGameObject (UnityEngine.Object)
0x000001d68142313b (Mono JIT Code) UnityEditor.GameObjectInspector/PreviewData:.ctor (UnityEngine.Object,bool)
[Worker0] 00 00 00 00 00 00 00 00 f0 47 43 91 d4 01 00 00 .........GC.....
[Worker0] 00 00 00 00 00 00 00 00 05 00 00 00 00 00 00 00 ................
[Worker0] Allocation of 32 bytes at c006fe30 in block 0 (frameIndex=0, lifetime=4, age=1, state=OK)
0x00007ff709a33aa3 (Unity) DirectorManager::ScheduleGraphDestroy
0x00007ff709e9be3b (Unity) Animator::ClearInternalControllerPlayableGraph
0x00007ff709ea273f (Unity) Animator::MainThreadCleanup
0x00007ff7093f7e0c (Unity) delete_object_internal_step1
0x00007ff70973df42 (Unity) CommitBatchDelete
0x00007ff70972727d (Unity) DestroyObjectHighLevel_Internal
0x00007ff709726e24 (Unity) DestroyObjectHighLevel
0x00007ff7097ac773 (Unity) RuntimeSceneManager::UnloadSceneInternal
0x00007ff70a9d0485 (Unity) EditorSceneManager::ClosePreviewScene
0x00007ff70916decf (Unity) EditorSceneManager_CUSTOM_ClosePreviewScene_Injected
0x000001d681445b0a (Mono JIT Code) (wrapper managed-to-native) UnityEditor.SceneManagement.EditorSceneManager:ClosePreviewScene_Injected (UnityEngine.SceneManagement.Scene&)
0x000001d681445a33 (Mono JIT Code) UnityEditor.SceneManagement.EditorSceneManager:ClosePreviewScene (UnityEngine.SceneManagement.Scene)
0x000001d681445873 (Mono JIT Code) UnityEditor.PreviewScene:smile:ispose ()
0x000001d6814457a3 (Mono JIT Code) UnityEditor.PreviewRenderUtility:Cleanup ()
0x000001d68144564b (Mono JIT Code) UnityEditor.GameObjectInspector/PreviewData:smile:ispose ()
0x000001d681444f53 (Mono JIT Code) UnityEditor.GameObjectInspector:OnDisable ()
0x000001d68013c508 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
0x00007ffe469f0394 (mono-2.0-bdwgc) mono_jit_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/mini/mini-runtime.c:3445)
0x00007ffe4692eb44 (mono-2.0-bdwgc) do_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/metadata/object.c:3066)
[Worker0] 40 6a 02 c0 d5 01 00 00 f0 47 43 91 d4 01 00 00 @j.......GC.....
[Worker0] 02 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 ................
TrimDiskCacheJob: Current cache size 4mb
Asset Pipeline Refresh (id=9cfd2babd7c14524a9758d20d38f20f0): Total: 0.104 seconds - Initiated by RefreshV2(AllowForceSynchronousImport)
Thanks a lot for this info is supper useful. I check our code and contacted team who work on this code so they investigate it further.
Small follow up. Thanks to information you provided our devs found reproduction of this issue and will be looking into resolving it :]
I’m using unity 2022.2.5f1 the same/similar problem keeps popping up
Received Import Request.
Time since last request: 0.000016 seconds.
path: Assets/Game/Global/GameplayUI/Sprites/Weapon_Icon.png
artifactKey: Guid(bf05ab72c260c7444b5c4d2e719376fc) Importer(2089858483,0ecaa5967403d082aa24f35e1b516d23)
Start importing Assets/Game/Global/GameplayUI/Sprites/Weapon_Icon.png using Guid(bf05ab72c260c7444b5c4d2e719376fc) Importer(2089858483,0ecaa5967403d082aa24f35e1b516d23) Generated GUIDs only implemented for interfaces!
-> (artifact id: 'b3343daf6c5b36cc7c3c1311e152cae2') in 0.010873 seconds
Internal: There are remaining Allocations on the JobTempAlloc. This is a leak, and will impact performance
To Debug, run app with -diag-job-temp-memory-leak-validation cmd line argument. This will output the callstacks of the leaked allocations.
Allocation of 32 bytes at 401d10a0 in block 0 (frameIndex=4, lifetime=4, age=0, state=OK)
0x00007ff701a232eb (Unity) PlayableGraph::smile:estroyPlayableDeferred
0x00007ff701e90e31 (Unity) Animator::ClearInternalControllerPlayable
0x00007ff701e91049 (Unity) Animator::ClearObject
0x00007ff701e920cf (Unity) Animator::smile:eactivate
0x00007ff7013e7c35 (Unity) GameObject::ActivateAwakeRecursivelyInternal
0x00007ff7013e7a74 (Unity) GameObject::ActivateAwakeRecursivelyInternal
0x00007ff7013e7a74 (Unity) GameObject::ActivateAwakeRecursivelyInternal
0x00007ff7013e77f9 (Unity) GameObject::ActivateAwakeRecursively
0x00007ff7013eaa29 (Unity) GameObject::smile:eactivate
0x00007ff701794660 (Unity) UnityScene::OnGameObjectChangedScene
0x00007ff7019a4d8d (Unity) SceneManagerBindings::MoveGameObjectToScene
0x00007ff700c2d111 (Unity) SceneManager_CUSTOM_MoveGameObjectToScene_Injected
0x000002393468c705 (Mono JIT Code) (wrapper managed-to-native) UnityEngine.SceneManagement.SceneManager:MoveGameObjectToScene_Injected (UnityEngine.GameObject,UnityEngine.SceneManagement.Scene&)
0x000002393468c62b (Mono JIT Code) UnityEngine.SceneManagement.SceneManager:MoveGameObjectToScene (UnityEngine.GameObject,UnityEngine.SceneManagement.Scene)
0x0000023934690b33 (Mono JIT Code) UnityEditor.PreviewScene:AddManagedGO (UnityEngine.GameObject)
0x0000023934690ab3 (Mono JIT Code) UnityEditor.PreviewRenderUtility:AddManagedGO (UnityEngine.GameObject)
0x000002393468e943 (Mono JIT Code) UnityEditor.GameObjectInspector/PreviewData:UpdateGameObject (UnityEngine.Object)
0x000002393468ad5b (Mono JIT Code) UnityEditor.GameObjectInspector/PreviewData:.ctor (UnityEngine.Object,bool)
0x000002393468a583 (Mono JIT Code) UnityEditor.GameObjectInspector:GetPreviewData (bool)
00 00 00 00 00 00 00 00 80 dd 35 11 37 02 00 00 ..........5.7...
00 00 00 00 00 00 00 00 05 00 00 00 00 00 00 00 ................
Allocation of 32 bytes at 4033fbe0 in block 1 (frameIndex=4, lifetime=4, age=0, state=OK)
0x00007ff701a27e03 (Unity) DirectorManager::ScheduleGraphDestroy
0x00007ff701e90edb (Unity) Animator::ClearInternalControllerPlayableGraph
0x00007ff701e977df (Unity) Animator::MainThreadCleanup
0x00007ff7013dde8c (Unity) delete_object_internal_step1
0x00007ff701727372 (Unity) CommitBatchDelete
0x00007ff70171041d (Unity) DestroyObjectHighLevel_Internal
0x00007ff70170ffc4 (Unity) DestroyObjectHighLevel
0x00007ff701795da3 (Unity) RuntimeSceneManager::UnloadSceneInternal
0x00007ff7029c1e65 (Unity) EditorSceneManager::ClosePreviewScene
0x00007ff70118e52f (Unity) EditorSceneManager_CUSTOM_ClosePreviewScene_Injected
0x0000023934751efa (Mono JIT Code) (wrapper managed-to-native) UnityEditor.SceneManagement.EditorSceneManager:ClosePreviewScene_Injected (UnityEngine.SceneManagement.Scene&)
0x0000023934751e23 (Mono JIT Code) UnityEditor.SceneManagement.EditorSceneManager:ClosePreviewScene (UnityEngine.SceneManagement.Scene)
0x0000023934751c63 (Mono JIT Code) UnityEditor.PreviewScene:smile:ispose ()
0x0000023934751b93 (Mono JIT Code) UnityEditor.PreviewRenderUtility:Cleanup ()
0x0000023934751a1b (Mono JIT Code) UnityEditor.GameObjectInspector/PreviewData:smile:ispose ()
0x0000023934751253 (Mono JIT Code) UnityEditor.GameObjectInspector:OnDisable ()
0x00000238f1f9f4a8 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
0x00007ffa6c040394 (mono-2.0-bdwgc) mono_jit_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/mini/mini-runtime.c:3445)
0x00007ffa6bf7eb44 (mono-2.0-bdwgc) do_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/metadata/object.c:3066)
a0 10 1d 40 38 02 00 00 80 dd 35 11 37 02 00 00 ...@8.....5.7...
02 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 ................
Number of updated asset objects reloaded before import = 0
Number of asset objects unloaded after import = 10
It seems its popping up from multiple different type of asset, at least +900
I can provide more info if needed, one weird thing is that the warning “-diag-job-temp-memory-leak-validation” keeps popping up even when using the argument and having JobTempMemoryLeak activated.
Hi, @SwingWren
I can provide more info if needed,
It is ok. From what I can see that this callstack is similar to the one that we seen previously.
one weird thing is that the warning “-diag-job-temp-memory-leak-validation” keeps popping up even when using the argument and having JobTempMemoryLeak activated.
We corrected this behaviour in 2023.2.0a1. In this version it should no longer log about command line when running with it.
Any word on this still? I’m getting frequently blasted with these errors after upgrading from 2021 to 2022. Often, simply navigating the folders will throw these errors. I don’t use any of those low level jobs or memory access things, so this shouldn’t be anything on my end. I’m using Unity 2022.2.12.
I’m having difficulty interpreting this phrase.
Does this mean that the root cause of the memory leaks has been fixed (in the beta version?), or does it mean that the error message has been suppressed?