Unity版本:2021
报错: A Native Collection has not been disposed, resulting in a memory leak. Enable Full StackTraces to get more details.
应该是 UnityWebRequest 或者是 WWW 没有释放,但是没有堆栈,无法追踪
解决方案
NativeArray 堆栈跟踪似乎与可以从控制台菜单操作的堆栈跟踪不同。只需将 NativeLeakDetection.Mode 更改 EnabledWithStackTrace
using UnityEngine;
using Unity.Collections;
public class MainLaunch: MonoBehaviour
{
void Start()
{
NativeLeakDetection.Mode = NativeLeakDetectionMode.EnabledWithStackTrace;
}
}
再次触发报错,显示具体堆栈行数