A Native Collection has not been disposed, resulting in a memory leak. Enable Full StackTraces to get more details.
Package manager中添加 com.unity.entities
添加完成后上方的Menu中会有Jobs按钮, Jobs -> Leak Detection -> Full Stack Traces (Expensive)就可以打开了.
原文链接:No information on error with full stack traces enabled - Unity Answers
至于为啥出现这个问题是在于频繁使用post请求导致内存泄漏.
这是因为在使用完UnityWebRequest对象后未能调用Dispose方法释放文章来源:https://www.toymoban.com/news/detail-507417.html
解决方法
在UnityWebRequest外添加一层using(){},这样在离开代码块时会自动调用dispose()方法文章来源地址https://www.toymoban.com/news/detail-507417.html
public static IEnumerator UnityWebRequestPost(string url, string json, Action<string> acticn)
{
using (UnityWebRequest www = UnityWebRequest.Post(url, json))
{
www.SetRequestHeader("Content-Type", "application/json;charset=utf-8");
byte[] bodyRaw = Encoding.UTF8.GetBytes(json);
www.uploadHandler = new UploadHandlerRaw(bodyRaw);
yield return www.SendWebRequest();
if (www.result == UnityWebRequest.Result.ProtocolError || www.result == UnityWebRequest.Result.ConnectionError)
{
Debug.LogError($"发起网络请求失败: 确认过闸接口 -{www.error}");
}
else
{
Debug.Log(www.downloadHandler.text);
acticn?.Invoke(www.downloadHandler.text);
}
}
}
到了这里,关于A Native Collection has not been disposed, resulting in a memory leak. Enable Full StackTraces to ge的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!