question

raul-jeri-lara avatar image
raul-jeri-lara asked

A Native Collection has not been disposed, resulting in a memory leak. Enable Full StackTraces to get more details.

The error "A Native Collection has not been disposed, resulting in a memory leak. Enable Full StackTraces to get more details." It always appears to me. I have tried to uninstall and install again, but nothing works for me.

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

Rick Chen avatar image Rick Chen ♦ commented ·

Do you mean installing PlayFabSDK on Unity? If so, what is the version of the PlayFabSDK and Unity you are working on? Can you please try upgrading to the latest version of PlayFabSDK?

0 Likes 0 ·
raul-jeri-lara avatar image raul-jeri-lara Rick Chen ♦ commented ·

My unity version is 2021.3.10f1 and my PlayFabSDK is 2.152.221010 (latest). No improvement after update.

0 Likes 0 ·
raul-jeri-lara avatar image raul-jeri-lara Rick Chen ♦ commented ·

I just installed unity jobs to read the full message:
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) PlayFab.PfEditor.PlayFabEditor:OnFocus() (at Assets\PlayFabEditorExtensions\Editor\PlayFabEditor.cs:62) UnityEditor.HostView:RegisterSelectedPane(Boolean) UnityEditor.HostView:OnEnable() UnityEditor.DockArea:OnEnable()

0 Likes 0 ·
raul-jeri-lara avatar image raul-jeri-lara Rick Chen ♦ commented ·

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, GetTitleDataRequest, Action`1, Action`1) (at Assets\PlayFabEditorExtensions\Editor\Scripts\PlayFabEditorSDK\PlayFabEditorHttp.cs:74) PlayFab.PfEditor.PlayFabEditorApi:GetTitleData(Action`1, Action`1) (at Assets\PlayFabEditorExtensions\Editor\Scripts\PlayFabEditorSDK\PlayFabEditorApi.cs:46) PlayFab.PfEditor.TitleDataViewer:RefreshTitleData() (at Assets\PlayFabEditorExtensions\Editor\Scripts\Components\TitleDataViewer.cs:122) PlayFab.PfEditor.PlayFabEditorDataMenu:DrawDataPanel() (at Assets\PlayFabEditorExtensions\Editor\Scripts\Panels\PlayFabEditorDataMenu.cs:38) PlayFab.PfEditor.PlayFabEditor:OnGuiInternal() (at Assets\PlayFabEditorExtensions\Editor\PlayFabEditor.cs:134) PlayFab.PfEditor.PlayFabEditor:HideRepaintErrors(Action) (at Assets\PlayFabEditorExtensions\Editor\PlayFabEditor.cs:172)

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

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.<>c:<OnLoginButtonClicked>b__14_0(LoginResult) (at Assets\PlayFabEditorExtensions\Editor\Scripts\Panels\PlayFabEditorAuthenticate.cs:284)

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

PlayFab.PfEditor.PlayFabEditorHttp:OnWwwSuccess(String, Action`1, Action`1, String) (at Assets\PlayFabEditorExtensions\Editor\Scripts\PlayFabEditorSDK\PlayFabEditorHttp.cs:124) PlayFab.PfEditor.<>c__DisplayClass2_0`2:<MakeApiCall>b__0(String) (at Assets\PlayFabEditorExtensions\Editor\Scripts\PlayFabEditorSDK\PlayFabEditorHttp.cs:95) PlayFab.PfEditor.<Post>d__7:MoveNext() (at Assets\PlayFabEditorExtensions\Editor\Scripts\PlayFabEditorSDK\PlayFabEditorHttp.cs:179) PlayFab.PfEditor.EditorCoroutine:Update() (at Assets\PlayFabEditorExtensions\Editor\Scripts\Utils\EditorCoroutine.cs:103) UnityEditor.EditorApplication:Internal_CallUpdateFunctions()

0 Likes 0 ·
raul-jeri-lara avatar image
raul-jeri-lara answered

I removed playfab editor extensions and it seems to have worked. I will write any news here. Thanks.

10 |1200

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

Rick Chen avatar image
Rick Chen answered

Currently there is some issue with using PlayFab Editor Extension in Unity new versions. But the PlayFab Unity SDK is still working.

The PlayFab Editor Extension isn't necessary to connect to the PlayFab service. You can remove it and use the PlayFab Unity SDK only.

10 |1200

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

Rick Chen avatar image
Rick Chen answered

Or you can fix the PlayFab Editor Extension yourself. Referring to this Unity forum case: A Native Collection has not been disposed, resulting in a memory leak. - Unity Forum

You can go to Assets\PlayFabEditorExtensions\Editor\Scripts\PlayFabEditorSDK\PlayFabEditorHttp.cs:74

and edit the code as

            var www = new UnityWebRequest(url)
            {
                uploadHandler = new UploadHandlerRaw(payload),
                downloadHandler = new DownloadHandlerBuffer(),
                method = "POST"
            };
            //Add these two lines
            www.disposeUploadHandlerOnDispose = true;
            www.disposeDownloadHandlerOnDispose = true;

then go to the Post function in the same file, change it to:

            if (www != null)
            {
                yield return www.SendWebRequest();
                if (!string.IsNullOrEmpty(www.error))
                    errorCallback(www.error);
                else
                    callBack(www.downloadHandler.text);
                //Add this line
                www.Dispose();
            }
            else
            {
                UnityEngine.Debug.Log("UnityWebRequest was null");
                errorCallback("UnityWebRequest Object was null");
            }
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.

george@thenuum.com avatar image george@thenuum.com commented ·

Will this get updated to playfab? I put it in, but if the sdk gets updated it gets reverted.

1 Like 1 ·
chronocantway avatar image chronocantway commented ·

Seemed to work. Easy fix. Thanks!

0 Likes 0 ·
hippogamesunity avatar image
hippogamesunity answered

Hi! Also get this error. The full stack is: 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:85) PlayFab.PfEditor.PlayFabEditorApi:GetStudios(GetStudiosRequest, Action`1, Action`1) (at Assets\PlayFabEditorExtensions\Editor\Scripts\PlayFabEditorSDK\PlayFabEditorApi.cs:35) 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)

Rick Chen's solutions works.

10 |1200

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

Damian Rajamanie avatar image
Damian Rajamanie answered

6247-image.png


image.png (66.3 KiB)
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.