NavidK0 / SimpleGraphQL-For-Unity

A simple graphQL client that allows one to use .graphql files (or code) for queries, mutations, and subscriptions with Unity.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A Native Collection has not been disposed, resulting in a memory leak. Allocated from: Unity.Collections.NativeArray

skjalgsm opened this issue · comments

You have to dispose the UnityWebRequest and its UploadHandler and Downloadhandler when its not in use any more.

The reason why you are not seeing this error (but will still experience leaking and memory build up) is because UnityWebRequest is using NativeArray, but the warnings associated with it can just be turned on (and off again) if you install the Burst package into your project. So its a good tip to install that, then turn on the debugging, and uninstall it again. That way you will always see this error when you forget to Dispose.

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[])
SimpleGraphQL.<PostRequestAsync>d__5:MoveNext() (at D:\statespacelabs\Packages\SimpleGraphQL-For-Unity\Runtime\SimpleGraphQL\HttpUtils.cs:53)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:Start(<PostRequestAsync>d__5&)
SimpleGraphQL.HttpUtils:PostRequestAsync(String, Request, Dictionary`2, String, String)
SimpleGraphQL.<Send>d__6:MoveNext() (at D:\statespacelabs\Packages\SimpleGraphQL-For-Unity\Runtime\SimpleGraphQL\GraphQLClient.cs:76)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:Start(<Send>d__6&)
SimpleGraphQL.GraphQLClient:Send(Request, Dictionary`2, String, String)
SimpleGraphQL.<Send>d__7`1:MoveNext() (at D:\statespacelabs\Packages\SimpleGraphQL-For-Unity\Runtime\SimpleGraphQL\GraphQLClient.cs:94)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:Start(<Send>d__7`1&)
SimpleGraphQL.GraphQLClient:Send(Request, Dictionary`2, String, String)
AimLab.GraphQL.<QueryInternal>d__15`1:MoveNext() (at Assets\Runtime\GraphQLUtility.cs:162)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:Start(<QueryInternal>d__15`1&)
AimLab.GraphQL.GraphQLUtility:QueryInternal(GraphQLConfig, AccessTokenResponse, String, OperationType, Object, Int32)
AimLab.GraphQL.<Query>d__14`1:MoveNext() (at Assets\Runtime\GraphQLUtility.cs:147)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:Start(<Query>d__14`1&)
AimLab.GraphQL.GraphQLUtility:Query(AccessTokenResponse, String, OperationType, Object)

Ahh, interesting. This message has sometimes appeared in our test project without a stack trace, so I wasn't sure where it was coming from.

It should be an easy fix, though.