How to reproduce:
1. Open the user’s attached “Test” project
2. Build and Run the “main” Scene
3. Take and open a snapshot of the Player in the Memory Profiler
Expected result: No error is thrown
Actual result: Errors are thrown when opening the snapshot or Player crashes
Reproducible with: 0.7.1-preview.1 (2021.3.18f1), 1.0.0 (2022.2.5f1, 2023.1.0b2)
Not reproducible with: 0.7.1-preview.1 (2020.3.44f1)
Reproduced on: macOS 13.0 (Intel)
Thrown errors:
OverflowException
Unity.MemoryProfiler.Editor.CachedSnapshot.ConvertDynamicArrayByteBufferToManagedArray[T]
…
A Native Collection has not been disposed, resulting in a memory leak. Enable Full StackTraces to get more details.
Stacktrace:
0 GameAssembly.dylib 0x12d5df6d6 il2cpp::vm::Class::GetVirtualMethod(Il2CppClass*, MethodInfo const*) + 166
1 GameAssembly.dylib 0x12d57227e il2cpp::metadata::GenericMetadata::InflateRGCTXLocked(Il2CppImage const*, unsigned int, Il2CppGenericContext const*, il2cpp::os::FastAutoLock const&) + 670 (GenericMetadata.cpp:290)
2 GameAssembly.dylib 0x12d5dd9c0 il2cpp::vm::Class::InitLocked(Il2CppClass*, il2cpp::os::FastAutoLock const&) + 880 (Class.cpp:1566)
3 GameAssembly.dylib 0x12d5dae56 il2cpp::vm::Class::Init(Il2CppClass*) + 102 (Class.cpp:1602)
4 GameAssembly.dylib 0x12d5d278c il2cpp::vm::Type::GetNameChunkedRecurseInternal(Il2CppType const*, Il2CppTypeNameFormat, bool, void ()(void, void*), void*) + 268 (Type.cpp:927)
5 UnityPlayer.dylib 0x10f582c86 MemorySnapshotProcess::AfterScriptingTypesHaveBeenReported() + 2726
Notes:
- In some versions, the Memory Profiler freezes at taking the snapshot where normally in Mono builds it takes in 2 seconds.
- Difficult to find the regression point as in the most alpha and beta versions of 2021.1 and 2021.2 streams, Memory Profiler isn’t compiled.