Search Issue Tracker
Fixed
Fixed in 1.8.1
Votes
5
Found in [Package]
1.7.8
Issue ID
UVSB-2417
Regression
No
Large amount of memory used in AOT Prebuild
When Visual Scripting creates the AOT stubs during a build, it loads every asset in the game to check if the main object inherits from IAotStubbable. This results in huge memory usage in large projects (in our case, it often causes a crash on a PC with 64GB of RAM)
There's a trivial code fix which is that you can check the asset type *without* loading the asset.
In AssetUtility.cs, replace GetAllAssetsOfType<T> with this version:
{code:java}
public static IEnumerable<T> GetAllAssetsOfType<T>()
{
if (typeof(UnityObject).IsAssignableFrom(typeof(T)))
{
return AssetDatabase.FindAssets($"t:{typeof(T).Name}")
.Select(AssetDatabase.GUIDToAssetPath)
.Select(AssetDatabase.LoadMainAssetAtPath)
.OfType<T>();
}
else
{
// GetAllAssetPaths is undocumented and sometimes returns
// paths that are outside the assets folder, hence the where filter.
var result = AssetDatabase.GetAllAssetPaths()
.Where(p => p.StartsWith("Assets"))
.Where(p => typeof(T).IsAssignableFrom(AssetDatabase.GetMainAssetTypeAtPath(p)))
.Select(AssetDatabase.LoadMainAssetAtPath)
.OfType<T>();
EditorUtility.UnloadUnusedAssetsImmediate();
return result;
}
}
{code}
This both reduces the memory usage, and improves the performance.
-
PanthenEye
Jul 05, 2023 17:24
Can we please get at least one hotfix this year? This was found in 1.7.8, which released more than a year ago.
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Articulation Body with 'Revolute' Joint Type has erratic behavior when Upper Limit is set to above 360
- WebGL Player fails to render Scene when Terrain with Detail Mesh is added and WebGPU Graphics API is used
- Inconsistent errors are logged when different types are passed into the Query "Q<>" method in UIToolkit and the ancestor VisualElement is null
- Crash on GetMaterialPropertyByIndex when opening a specific Scene
- Discrepancies in the styling are present when using a TSS file instead of a USS file in custom EditorWindow
Resolution Note (fix version 1.8.1):
Optimising AOT Prebuild by checking the type of assets without always loading it.
Fixed in 1.9.0