question

Chethan V avatar image
Chethan V asked

A Native Collection has not been disposed after adding PlayFab in Unity

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.

1 Answer

·
Gosen Gao avatar image
Gosen Gao answered

We noticed that the error is from PlayFab Extension, Since it won't be involved in build or game process, you can ignore this issue. And the Extension can be removed if you want. But if you want to fix it, you can add www.Dispose() to the end of each Ienumerator(Post/PostDownload) to clean up any resources it is using when the UnityWebRequest is no longer being used.

4 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.

Thomas Moon Kang avatar image Thomas Moon Kang commented ·

Okay, why haven't you guys updated the PlayFab Extension?

1 Like 1 ·
Chethan V avatar image Chethan V commented ·

I closed Unity,deleted the Library folder and restarted Unity. Unity automatically imported the necessary files and the error went away.

0 Likes 0 ·
raul-jeri-lara avatar image raul-jeri-lara Chethan V commented ·

@Chethan V Which library should I remove? I have the same problem

0 Likes 0 ·
dylanjameshogan avatar image dylanjameshogan commented ·

How do you add www.Dispose() to the end of each Ienumerator(Post/PostDownload)?

0 Likes 0 ·

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.