question

ferdi77 avatar image
ferdi77 asked

Memory leak error after adding playfab to my unity project

After I set up playfab in my unity project, the following error appeared in the console:

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[]) PlayFab.PfEditor.PlayFabEditorHttp:MakeApiCall(String, String, GetStudiosRequest, Action`1, Action`1) (at Assets\PlayFabEditorExtensions\Editor\Scripts\PlayFabEditorSDK\PlayFabEditorHttp.cs:74) PlayFab.PfEditor.PlayFabEditorApi:GetStudios(GetStudiosRequest, Action`1, Action`1) (at Assets\PlayFabEditorExtensions\Editor\Scripts\PlayFabEditorSDK\PlayFabEditorApi.cs:30) PlayFab.PfEditor.PlayFabEditorDataService:RefreshStudiosList(Boolean) (at Assets\PlayFabEditorExtensions\Editor\Scripts\Utils\PlayFabEditorDataService.cs:198) PlayFab.PfEditor.PlayFabEditor:OnEnable() (at Assets\PlayFabEditorExtensions\Editor\PlayFabEditor.cs:45) PlayFab.PfEditor.PlayFabEditor:OnFocus() (at Assets\PlayFabEditorExtensions\Editor\PlayFabEditor.cs:62) UnityEditor.HostView:RegisterSelectedPane(Boolean) UnityEditor.HostView:OnEnable() UnityEditor.DockArea:OnEnable()

How can I fix this? I tried so many things, searched on google,but I can't solve the problem.

My unity version: 2021.2.1f1

entities
2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Seth Du avatar image Seth Du ♦ commented ·

What's the version of PlayFab Unity Extension? I will try to reproduce.

0 Likes 0 ·
Aliona Kotuseva avatar image Aliona Kotuseva Seth Du ♦ commented ·

Same problem here. Unity 2021.2.5f1 + Playfab SDK 2.116.211012 (it won't let me update to a newer version by the way but that's a problem for another day).

Clean project with nothing but playfab in it.

0 Likes 0 ·
Chethan V avatar image
Chethan V answered

Same problem here. Unity 2021.2.5f1 + Playfab SDK 2.116.211012

Full problem here:

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[]) PlayFab.PfEditor.PlayFabEditorHttp:MakeApiCall(String, String, GetStudiosRequest, Action`1, Action`1) (at Assets\PlayFabEditorExtensions\Editor\Scripts\PlayFabEditorSDK\PlayFabEditorHttp.cs:74) PlayFab.PfEditor.PlayFabEditorApi:GetStudios(GetStudiosRequest, Action`1, Action`1) (at Assets\PlayFabEditorExtensions\Editor\Scripts\PlayFabEditorSDK\PlayFabEditorApi.cs:30) PlayFab.PfEditor.PlayFabEditorDataService:RefreshStudiosList(Boolean) (at Assets\PlayFabEditorExtensions\Editor\Scripts\Utils\PlayFabEditorDataService.cs:197) PlayFab.PfEditor.PlayFabEditor:OnEnable() (at Assets\PlayFabEditorExtensions\Editor\PlayFabEditor.cs:45)

,

@SethDu same problem here Unity 2021.2.5f1 Personal + Playfab SDK 2.116.211012....Here is the full length of the probem

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[]) PlayFab.PfEditor.PlayFabEditorHttp:MakeApiCall(String, String, GetStudiosRequest, Action`1, Action`1) (at Assets\PlayFabEditorExtensions\Editor\Scripts\PlayFabEditorSDK\PlayFabEditorHttp.cs:74) PlayFab.PfEditor.PlayFabEditorApi:GetStudios(GetStudiosRequest, Action`1, Action`1) (at Assets\PlayFabEditorExtensions\Editor\Scripts\PlayFabEditorSDK\PlayFabEditorApi.cs:30) PlayFab.PfEditor.PlayFabEditorDataService:RefreshStudiosList(Boolean) (at Assets\PlayFabEditorExtensions\Editor\Scripts\Utils\PlayFabEditorDataService.cs:197) PlayFab.PfEditor.PlayFabEditor:OnEnable() (at Assets\PlayFabEditorExtensions\Editor\PlayFabEditor.cs:45)

I saw in the line 74...... it was saying

var www = new UnityWebRequest(url) { uploadHandler = new UploadHandlerRaw(payload), downloadHandler = new DownloadHandlerBuffer(), method = "POST" };

I tried using the "using" statement as suggested somewhere else but I am getting error. Maybe I am not using it the right way.

I am not able to build my game, it is taking a long time and I suspect this might be the issue

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Chethan V avatar image
Chethan V answered

Please ignore the above answer, I dont know why there is no option to delete it

So this is how I solved the error. I closed Unity,deleted the Library folder and restarted Unity. Unity automatically imported the necessary files and the error went away. Hope this helps someone

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.