Quite frequently I get a memory allocation error in unity at compile time. Afaik this can be due to a very high number of assets, or due to an asset that might be too large.
I observed that most of the time the amount of memory that produces the problem is the same: 134217728B with 16 alignment.
Note the 'most of the time', not always.
1.- Is there a way to know what specific asset is related to the amount of memory that failed to be allocated in the crash?
2.- Is there a way to evaluate the amount of ram memory your machine might need according to the size of a project, the number of assets or any other relevant parameter?
The crash is related with the lack of me for some compilation task. My point is that even if this kind of errors are hard to identify/debug solve, the fact the the size to allocate is almost always the same (in this case 134217728), there could be some hint to get to know the asset resposible or some proposal of action to prevent the crash.
Edit:
Up to what I am researching, reading the documentation, this seems to be the key: "Consider loading operations. If a large number of temporary objects are generated during a heavy Asset-loading operation, and those objects are referenced until the operation completes, then the garbage collector is unable to release those temporary objects and the managed heap needs to expand – even though many of the objects it contains will be released a short time later."
The key would then be to identify the problematic assets and slice those down for smoother memory allocation.
Image and relevant part of the log below.
Image:
Relevant part of the Editor.log:
Reloading assemblies after finishing script compilation.
Begin MonoManager ReloadAssembly
DynamicHeapAllocator allocation probe 1 failed - Could not get memory for large allocation 134217728.
DynamicHeapAllocator allocation probe 2 failed - Could not get memory for large allocation 134217728.
DynamicHeapAllocator allocation probe 3 failed - Could not get memory for large allocation 134217728.
DynamicHeapAllocator allocation probe 4 failed - Could not get memory for large allocation 134217728.
DynamicHeapAllocator out of memory - Could not get memory for large allocation 134217728!
Could not allocate memory: System out of memory!
Trying to allocate: 134217728B with 16 alignment. MemoryLabel: DynamicArray
Allocation happened at: Line:75 in C:\buildslave\unity\build\Runtime/Utilities/dynamic_array.h
Memory overview
[ ALLOC_DEFAULT ] used: 1759593661B | peak: 0B | reserved: 2040112693B
[ ALLOC_TEMP_JOB ] used: 0B | peak: 0B | reserved: 16777216B
[ ALLOC_TEMP_BACKGROUND_JOB ] used: 0B | peak: 0B | reserved: 1048576B
[ ALLOC_GFX ] used: 9760199558B | peak: 0B | reserved: 9803569966B
[ ALLOC_CACHEOBJECTS ] used: 547232668B | peak: 0B | reserved: 810108412B
[ ALLOC_TYPETREE ] used: 102395080B | peak: 0B | reserved: 119537664B
[ ALLOC_PROFILER ] used: 63528720B | peak: 63834568B | reserved: 67108864B
[ ALLOC_PROFILER_EDITOR ] used: 22288B | peak: 31520B | reserved: 1048576B
[ ALLOC_TEMP_THREAD ] used: 32768B | peak: 0B | reserved: 23199744B
Could not allocate memory: System out of memory!
Trying to allocate: 134217728B with 16 alignment. MemoryLabel: DynamicArray
Allocation happened at: Line:75 in C:\buildslave\unity\build\Runtime/Utilities/dynamic_array.h
Memory overview
[ ALLOC_DEFAULT ] used: 1759593661B | peak: 0B | reserved: 2040112693B
[ ALLOC_TEMP_JOB ] used: 0B | peak: 0B | reserved: 16777216B
[ ALLOC_TEMP_BACKGROUND_JOB ] used: 0B | peak: 0B | reserved: 1048576B
[ ALLOC_GFX ] used: 9760199558B | peak: 0B | reserved: 9803569966B
[ ALLOC_CACHEOBJECTS ] used: 547232668B | peak: 0B | reserved: 810108412B
[ ALLOC_TYPETREE ] used: 102395080B | peak: 0B | reserved: 119537664B
[ ALLOC_PROFILER ] used: 63528720B | peak: 63834568B | reserved: 67108864B
[ ALLOC_PROFILER_EDITOR ] used: 22288B | peak: 31520B | reserved: 1048576B
[ ALLOC_TEMP_THREAD ] used: 32768B | peak: 0B | reserved: 23199744B
Edit: I post also the rest of the log, in case it might be of any help
[Performance] WebView.DoCefMessages : 2459 samples, Peak. 228 ms (374.1x), Avg. 609 us, Total. 1.497 s (0.0%)
[Performance] WebView.CheckCurlRequests : 699 samples, Peak. 230 us (103.8x), Avg. 2.22 us, Total. 1.550 ms (0.0%)
[Performance] License.Tick : 175393 samples, Peak. 12.0 ms (6922.7x), Avg. 1.73 us, Total. 303.2 ms (0.0%)
[Performance] UnityConnect.Tick : 94325 samples, Peak. 3.24 ms (490.2x), Avg. 6.61 us, Total. 623.6 ms (0.0%)
[Performance] PackageManager::RunRequestSynchronously : 4 samples, Peak. 37.4 ms (3.5x), Avg. 10.7 ms, Total. 42.74 ms (0.0%)
[Performance] ProjectBrowser.OnGUI : 2654 samples, Peak. 5.39 s (959.3x), Avg. 5.62 ms, Total. 14.91 s (0.2%)
[Performance] SceneHierarchyWindow.OnGUI : 21680 samples, Peak. 5.05 s (2197.0x), Avg. 2.30 ms, Total. 49.86 s (0.6%)
[Performance] InspectorWindow.OnGUI : 7630 samples, Peak. 3.12 s (208.8x), Avg. 14.9 ms, Total. 113.9 s (1.3%)
[Performance] GameView.OnGUI : 426770 samples, Peak. 535 ms (897.9x), Avg. 596 us, Total. 254.5 s (2.9%)
[Performance] ConsoleWindow.OnGUI : 2494 samples, Peak. 32.8 ms (64.9x), Avg. 505 us, Total. 1.260 s (0.0%)
[Performance] SceneView.OnGUI : 152351 samples, Peak. 310 ms (66.7x), Avg. 4.64 ms, Total. 707.3 s (8.2%)
[Performance] SceneButtons.OnGUI : 122 samples, Peak. 496 ms (115.2x), Avg. 4.31 ms, Total. 525.6 ms (0.0%)
[Performance] ApplicationTickTimer : 354737 samples, Peak. 499 s (40957.4x), Avg. 12.2 ms, Total. 4.320 ks (49.9%)
[Performance] VCProvider : 354738 samples, Peak. 447 us (318.4x), Avg. 1.41 us, Total. 498.5 ms (0.0%)
[Performance] MonoCompiler.Tick : 30126 samples, Peak. 16.2 s (25084.8x), Avg. 644 us, Total. 19.40 s (0.2%)
[Performance] Internal_SwitchSkin : 354737 samples, Peak. 28.7 us (744.5x), Avg. 38.5 ns, Total. 13.67 ms (0.0%)
[Performance] Collab.Tick : 93099 samples, Peak. 528 us (292.8x), Avg. 1.80 us, Total. 167.9 ms (0.0%)
[Performance] WebView.Tick : 172938 samples, Peak. 443 ms (5178.0x), Avg. 85.5 us, Total. 14.79 s (0.2%)
[Performance] CurlRequest.Tick : 56494 samples, Peak. 20.9 ms (12761.9x), Avg. 1.64 us, Total. 92.53 ms (0.0%)
[Performance] SceneBackgroundTask.Tick : 38635 samples, Peak. 62.4 us (268.6x), Avg. 232 ns, Total. 8.975 ms (0.0%)
[Performance] Scheduler.Tick : 298816 samples, Peak. 2.29 ms (63.6x), Avg. 36.1 us, Total. 10.77 s (0.1%)
[Performance] RepaintAllProfilerWindows : 11972 samples, Peak. 1.14 ms (674.7x), Avg. 1.68 us, Total. 20.15 ms (0.0%)
[Performance] PlayerUpdates.Tick : 93092 samples, Peak. 455 us (19.1x), Avg. 23.8 us, Total. 2.213 s (0.0%)
[Performance] GlobalCallbacks : 354737 samples, Peak. 291 ms (6080.2x), Avg. 47.8 us, Total. 16.96 s (0.2%)
[Performance] EditorAnalytics.Tick : 24515 samples, Peak. 290 ms (20095.9x), Avg. 14.4 us, Total. 353.7 ms (0.0%)
[Performance] GI.Tick : 937 samples, Peak. 860 us (22.1x), Avg. 38.9 us, Total. 36.46 ms (0.0%)
[Performance] Video.Update : 354737 samples, Peak. 306 us (403.3x), Avg. 760 ns, Total. 269.5 ms (0.0%)
[Performance] UnitySynchronization.ExecuteTasks : 4630 samples, Peak. 6.44 ms (899.0x), Avg. 7.16 us, Total. 33.14 ms (0.0%)
[Performance] Package.AsyncRequest : 10 samples, Peak. 108 us (8.9x), Avg. 12.1 us, Total. 121.0 us (0.0%)
[Performance] PreloadManager : 249203 samples, Peak. 357 us (58.7x), Avg. 6.08 us, Total. 1.516 s (0.0%)
[Performance] SceneTracker : 354737 samples, Peak. 2.12 s (6423.6x), Avg. 330 us, Total. 116.9 s (1.4%)
[Performance] ConsoleLog.Tick : 30117 samples, Peak. 261 us (88.0x), Avg. 2.97 us, Total. 89.44 ms (0.0%)
[Performance] HierarchyWindow.Tick : 36792 samples, Peak. 131 ms (1620.4x), Avg. 81.0 us, Total. 2.979 s (0.0%)
[Performance] Inspector.Tick : 36784 samples, Peak. 222 ms (14.4x), Avg. 15.4 ms, Total. 565.2 s (6.5%)
[Performance] Tooltip.Tick : 83723 samples, Peak. 221 ms (3980.2x), Avg. 55.4 us, Total. 4.641 s (0.1%)
[Performance] RequestRepaintForPanels : 351040 samples, Peak. 548 us (75.9x), Avg. 7.22 us, Total. 2.533 s (0.0%)
[Performance] UpdateSceneIfNeeded : 351040 samples, Peak. 498 s (57935.4x), Avg. 8.60 ms, Total. 3.019 ks (34.9%)
[Performance] UpdateVideoTextures : 4105 samples, Peak. 1.30 us (2.8x), Avg. 460 ns, Total. 1.887 ms (0.0%)
[Performance] PackageImporter.Tick : 30065 samples, Peak. 320 us (540.3x), Avg. 593 ns, Total. 17.82 ms (0.0%)
[Performance] InspectorBackground.Tick : 38566 samples, Peak. 198 us (244.3x), Avg. 810 ns, Total. 31.23 ms (0.0%)
[Performance] ChangeLayoutIfNeeded : 354737 samples, Peak. 124 ms (72989.2x), Avg. 1.70 us, Total. 604.1 ms (0.0%)
[Performance] AsyncReadManager.ForceCloseFiles : 6517 samples, Peak. 11.7 ms (1414.4x), Avg. 8.26 us, Total. 53.82 ms (0.0%)
[Performance] InactiveGI.Tick : 1235 samples, Peak. 977 us (24.5x), Avg. 39.9 us, Total. 49.28 ms (0.0%)
[Performance] RepaintAll : 3697 samples, Peak. 37.3 ms (647.1x), Avg. 57.7 us, Total. 213.4 ms (0.0%)
[Performance] AnimationWindow.OnGUI : 41 samples, Peak. 21.8 ms (14.9x), Avg. 1.46 ms, Total. 59.86 ms (0.0%)
[Performance] ConsolePro3Window.OnGUI : 55 samples, Peak. 158 ms (34.7x), Avg. 4.54 ms, Total. 249.8 ms (0.0%)
