Native Collection have not been disposed on game close

When closing game, once in a while I get

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[])
Unity.Services.Analytics.Internal.WebRequestHelper:CreateWebRequest(String, String, Byte[]) (at Library\PackageCache\com.unity.services.analytics@4.0.1\Runtime\Runtime\WebRequestHelper.cs:32)
Unity.Services.Analytics.Internal.<FlushBufferToService>d__13:MoveNext() (at Library\PackageCache\com.unity.services.analytics@4.0.1\Runtime\Runtime\Dispatcher.cs:79)
System.Runtime.CompilerServices.MoveNextRunner:InvokeMoveNext(Object)
System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean)
System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object, Boolean)
System.Runtime.CompilerServices.MoveNextRunner:Run()
System.Threading.Tasks.<>c:<.cctor>b__7_0(Object)
UnityEngine.WorkRequest:Invoke()
UnityEngine.UnitySynchronizationContext:Exec()
UnityEngine.UnitySynchronizationContext:ExecuteTasks()

You are probably not closing your WebRequest properly, can you please validate?

Thank

Hey @Morphus74

Could you provide me with the steps to reproduce this error.

I just have IAP/Analytics install, doing no specific transaction and just hitting stop in the editor

I have just seen this error too (with Analytics package 4.2.0), upon hitting Stop in the Editor.

A Native Collection has not been disposed, resulting in a memory leak. Allocated from:
Unity.Collections.NativeArray`1:.ctor(Byte[], Allocator) (at /Users/bokken/build/output/unity/unity/Runtime/Export/NativeArray/NativeArray.cs:69)
UnityEngine.Networking.UploadHandlerRaw:.ctor(Byte[]) (at /Users/bokken/build/output/unity/unity/Modules/UnityWebRequest/Public/UploadHandler/UploadHandler.bindings.cs:95)
Unity.Services.Analytics.Internal.WebRequestHelper:CreateWebRequest(String, String, Byte[]) (at Library/PackageCache/com.unity.services.analytics@4.2.0/Runtime/Runtime/WebRequestHelper.cs:32)
Unity.Services.Analytics.Internal.<FlushBufferToService>d__13:MoveNext() (at Library/PackageCache/com.unity.services.analytics@4.2.0/Runtime/Runtime/Dispatcher.cs:87)
System.Runtime.CompilerServices.MoveNextRunner:InvokeMoveNext(Object)
System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean)
System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object, Boolean)
System.Runtime.CompilerServices.MoveNextRunner:Run()
System.Threading.Tasks.<>c:<.cctor>b__7_0(Object)
UnityEngine.WorkRequest:Invoke() (at /Users/bokken/build/output/unity/unity/Runtime/Export/Scripting/UnitySynchronizationContext.cs:153)
UnityEngine.UnitySynchronizationContext:Exec() (at /Users/bokken/build/output/unity/unity/Runtime/Export/Scripting/UnitySynchronizationContext.cs:83)
UnityEngine.UnitySynchronizationContext:ExecuteTasks() (at /Users/bokken/build/output/unity/unity/Runtime/Export/Scripting/UnitySynchronizationContext.cs:107)

But this might be related to WebRequest's Dispose not working properly?

Others are having issue too:
https://discussions.unity.com/t/847206

Also, I have this error coming from the Playfab SDK even if they are calling Dispose on the UnityWebRequest