Editor crashes when execute AssetDatabase.CreateAsset
to save mesh that has about 150,000,000 vertices.
I made a mesh object with C# script, and trying to save it with AssetDatabse.CreateAsset();
. Here's my code for save asset ↓
AssetDatabase.StartAssetEditing();
AssetDatabase.CreateAsset(tempMesh, $"Assets/Export/{fileName}.asset");
AssetDatabase.StopAssetEditing();
I can save a mesh when the vertices of the tempmesh is about 80,000 (I already added tempMesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32;
), but the editor crashes if that is about 150,000,000.
I'm thinking of separating mesh per 100,000 vertices (making 1,500 meshes), then generate object for each mesh. But I don't want to separate as much as possible.
What can I do to save mesh that has about 150,000,000 vertices?
Here's the log when the editor crashed.
Obtained 46 stack frames.
#0 0x0000011048d0d1 in BytesToHexString(void const*, unsigned long, char*)
#1 0x0000011014044d in TextDOMTransferWriteBase<YAMLWrite>::TransferTypelessData(unsigned int, void*, TransferMetaFlags)
#2 0x0000011025898a in void VertexData::Transfer<YAMLWrite>(YAMLWrite&)
#3 0x0000010ff78f64 in void YAMLWrite::Transfer<VertexData>(VertexData&, char const*, TransferMetaFlags)
#4 0x00000111d3ab32 in void Mesh::Transfer<YAMLWrite>(YAMLWrite&)
#5 0x00000111d3a514 in void YAMLWrite::Transfer<Mesh>(Mesh&, char const*, TransferMetaFlags)
#6 0x000001106dabbf in void SerializedFile::WriteTextSerialized<Object>(core::basic_string<char, core::StringStorageDefault<char>>&, Object&, BuildUsageTag const&, TransferInstructionFlags)
#7 0x000001106da73e in SerializedFile::WriteObject(Object&, long long, short, BuildUsageTag const&, GlobalBuildData const&)
#8 0x000001106b9f6d in PersistentManager::WriteFile(core::basic_string_ref<char>, int, WriteData const*, int, GlobalBuildData const&, VerifyWriteObjectResult (*)(Object*, BuildTargetPlatform), BuildTargetSelection, TransferInstructionFlags, WriteInformation&, InstanceIDResolver const*, PersistentManager::LockFlags, int (*)(PersistentManager::ReportWriteObjectStep, int, core::basic_string<char, core::StringStorageDefault<char>> const&, int, void*), void*)
#9 0x000001106b8b23 in PersistentManager::WriteFile(core::basic_string_ref<char>, int, WriteData const*, int, GlobalBuildData const&, VerifyWriteObjectResult (*)(Object*, BuildTargetPlatform), BuildTargetSelection, TransferInstructionFlags, InstanceIDResolver const*, PersistentManager::LockFlags, int (*)(PersistentManager::ReportWriteObjectStep, int, core::basic_string<char, core::StringStorageDefault<char>> const&, int, void*), void*)
#10 0x000001110e11c8 in WriteObjectsToDiskThreadSafe(core::basic_string<char, core::StringStorageDefault<char>> const&, Object**, long long const*, unsigned long, TransferInstructionFlags)
#11 0x000001113e722f in CreateSerializedAssetV2(Object**, int, core::basic_string<char, core::StringStorageDefault<char>> const&, AssetDatabase::CreateAssetMask)
#12 0x00000111382c9c in AssetDatabase::CreateSerializedAsset(Object&, core::basic_string<char, core::StringStorageDefault<char>> const&, AssetDatabase::CreateAssetMask)
#13 0x00000111739d78 in AssetDatabaseBindings::CreateAsset(PPtr<Object>, core::basic_string<char, core::StringStorageDefault<char>> const&, ScriptingExceptionPtr*)
#14 0x000001117d7b04 in AssetDatabase_CUSTOM_CreateAsset(ScriptingBackendNativeObjectPtrOpaque*, ScriptingBackendNativeStringPtrOpaque*)
#15 0x000001b52959e5 in (wrapper managed-to-native) UnityEditor.AssetDatabase:CreateAsset (UnityEngine.Object,string) {0x7fc4732dab20} + 0x65 (0x1b5295980 0x1b5295a6d) [0x151982960 - Unity Child Domain]
#16 0x000001824d2fab in Cysharp.Threading.Tasks.CompilerServices.AsyncUniTask`1<MainAsync/<tengunMeshGenerator>d__3>:Run () {0x7fc471c24c10} + 0x2b (0x1824d2f80 0x1824d2fcb) [0x151982960 - Unity Child Domain]
#17 0x000001824dd2cb in Cysharp.Threading.Tasks.Internal.ContinuationQueue:Update () {0x7fc4729ea3d0} + 0x1b (0x1824dd2b0 0x1824dd2d0) [0x151982960 - Unity Child Domain]
#18 0x0000015683b1f5 in mono_jit_runtime_invoke
#19 0x000001569d9213 in do_runtime_invoke
#20 0x000001569d916d in mono_runtime_invoke
#21 0x0000011064c197 in scripting_method_invoke(ScriptingMethodPtr, ScriptingObjectPtr, ScriptingArguments&, ScriptingExceptionPtr*, bool)
#22 0x00000110647746 in ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool)
#23 0x00000110323cd9 in ExecutePlayerLoop(NativePlayerLoopSystem*)
#24 0x00000110323b65 in ExecutePlayerLoop(NativePlayerLoopSystem*)
#25 0x00000110323fb5 in PlayerLoop()
#26 0x00000110e930c2 in PlayerLoopController::UpdateScene(bool)
#27 0x00000110e8d207 in PlayerLoopController::UpdateSceneIfNeeded()
#28 0x00000110e8a664 in Application::TickTimer()
#29 0x000001121bca3f in -[EditorApplication TickTimer]
#30 0x007ff805399766 in __NSFireTimer
#31 0x007ff8044e9358 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__
#32 0x007ff8044e8ed3 in __CFRunLoopDoTimer
#33 0x007ff8044e8af9 in __CFRunLoopDoTimers
#34 0x007ff8044cee39 in __CFRunLoopRun
#35 0x007ff8044cdf31 in CFRunLoopRunSpecific
#36 0x007ff80df49dad in RunCurrentEventLoopInMode
#37 0x007ff80df49bbe in ReceiveNextEventCommon
#38 0x007ff80df49918 in _BlockUntilNextEventMatchingListInModeWithFilter
#39 0x007ff8075625d0 in _DPSNextEvent
#40 0x007ff80756147a in -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:]
#41 0x007ff807553ae8 in -[NSApplication run]
#42 0x007ff807527d02 in NSApplicationMain
#43 0x000001121d856d in EditorMain(int, char const**)
#44 0x000001121d8799 in main
#45 0x007ff80409a41f in start
Launching bug reporter
I assume that it is due to a lack of RAM. Your device has a total of 8 GB of RAM, excluding space for system and different app operations. In this case, the total free memory may be 6 GB or even less. I suggest checking the activity monitor while generating the mesh with 150,000,000. vertices, this will let you see if you have exceeded the amount of available resources