A Native Collection has not been disposed, resulting in a memory leak

799 views Asked by At
A Native Collection has not been disposed, resulting in a memory leak. Allocated from:
Unity.Collections.NativeArray`1:.ctor(Byte[], Allocator)
UnityEngine.Networking.UploadHandlerRaw:.ctor(Byte[])
UnityEngine.Networking.UnityWebRequest:SetupPost(UnityWebRequest, WWWForm)
UnityEngine.Networking.UnityWebRequest:Post(String, WWWForm)
<CreatePages>d__15:MoveNext() (at Assets\code\Word\SpawnWordsAndPages.cs:156)
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
UnityEngine.MonoBehaviour:StartCoroutineManaged2(MonoBehaviour, IEnumerator)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
SpawnWordsAndPages:Start() (at Assets\code\Word\SpawnWordsAndPages.cs:30)

SpawnWordsAndPages.cs:156:

UnityWebRequest www = UnityWebRequest.Post("http://localhost/GetWords.php", form);

SpawnWordsAndPages:Start() (at Assets\code\Word\SpawnWordsAndPages.cs:30):

StartCoroutine(CreatePages());
1

There are 1 answers

0
HyoJin KIM On

Try to handle with dispose();

You can use the 'using' statement to handle this easily.

using (UnityWebRequest www = UnityWebRequest.Post("http://localhost/GetWords.php", form))
{
yield return request.Send();
}

Check the official Unity3d Docs