From 3344ec368efcdddab186771de3157666b0e4decd Mon Sep 17 00:00:00 2001 From: GammaFoxTBG Date: Sat, 17 Dec 2022 11:41:56 -0600 Subject: [PATCH] Fixed memory leak when using EditorCoroutine.cs Fixed memory leak issue, caused by the EditorCoroutine class not disposing the web request after. ``` 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:85) PlayFab.PfEditor.PlayFabEditorApi:GetTitleInternalData(Action`1, Action`1) (at Assets\PlayFabEditorExtensions\Editor\Scripts\PlayFabEditorSDK\PlayFabEditorApi.cs:69) PlayFab.PfEditor.TitleInternalDataViewer:RefreshInternalTitleData() (at Assets\PlayFabEditorExtensions\Editor\Scripts\Components\TitleInternalDataViewer.cs:123) PlayFab.PfEditor.TitleInternalDataViewer:Draw() (at Assets\PlayFabEditorExtensions\Editor\Scripts\Components\TitleInternalDataViewer.cs:28) PlayFab.PfEditor.PlayFabEditorDataMenu:DrawDataPanel() (at Assets\PlayFabEditorExtensions\Editor\Scripts\Panels\PlayFabEditorDataMenu.cs:52) PlayFab.PfEditor.PlayFabEditor:OnGuiInternal() (at Assets\PlayFabEditorExtensions\Editor\PlayFabEditor.cs:146) PlayFab.PfEditor.PlayFabEditor:HideRepaintErrors(Action) (at Assets\PlayFabEditorExtensions\Editor\PlayFabEditor.cs:184) PlayFab.PfEditor.PlayFabEditor:OnGUI() (at Assets\PlayFabEditorExtensions\Editor\PlayFabEditor.cs:116) UnityEditor.HostView:InvokeOnGUI(Rect) UnityEditor.DockArea:DrawView(Rect) UnityEditor.DockArea:OldOnGUI() UnityEngine.UIElements.IMGUIContainer:DoOnGUI(Event, Matrix4x4, Rect, Boolean, Rect, Action, Boolean) UnityEngine.UIElements.IMGUIContainer:HandleIMGUIEvent(Event, Matrix4x4, Rect, Action, Boolean) UnityEngine.UIElements.IMGUIContainer:HandleIMGUIEvent(Event, Action, Boolean) UnityEngine.UIElements.IMGUIContainer:HandleIMGUIEvent(Event, Boolean) UnityEngine.UIElements.IMGUIContainer:SendEventToIMGUIRaw(EventBase, Boolean, Boolean) UnityEngine.UIElements.IMGUIContainer:SendEventToIMGUI(EventBase, Boolean, Boolean) UnityEngine.UIElements.IMGUIContainer:HandleEvent(EventBase) UnityEngine.UIElements.CallbackEventHandler:HandleEventAtTargetPhase(EventBase) UnityEngine.UIElements.MouseCaptureDispatchingStrategy:DispatchEvent(EventBase, IPanel) UnityEngine.UIElements.EventDispatcher:ApplyDispatchingStrategies(EventBase, IPanel, Boolean) UnityEngine.UIElements.EventDispatcher:ProcessEvent(EventBase, IPanel) UnityEngine.UIElements.EventDispatcher:ProcessEventQueue() UnityEngine.UIElements.EventDispatcher:OpenGate() UnityEngine.UIElements.EventDispatcherGate:Dispose() UnityEngine.UIElements.EventDispatcher:ProcessEvent(EventBase, IPanel) UnityEngine.UIElements.EventDispatcher:Dispatch(EventBase, IPanel, DispatchMode) UnityEngine.UIElements.BaseVisualElementPanel:SendEvent(EventBase, DispatchMode) UnityEngine.UIElements.UIElementsUtility:DoDispatch(BaseVisualElementPanel) UnityEngine.UIElements.UIElementsUtility:UnityEngine.UIElements.IUIElementsUtility.ProcessEvent(Int32, IntPtr, Boolean&) UnityEngine.UIElements.UIEventRegistration:ProcessEvent(Int32, IntPtr) UnityEngine.UIElements.<>c:<.cctor>b__1_2(Int32, IntPtr) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&) ``` --- .../Editor/Scripts/Utils/EditorCoroutine.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/ExampleTestProject/Assets/PlayFabEditorExtensions/Editor/Scripts/Utils/EditorCoroutine.cs b/ExampleTestProject/Assets/PlayFabEditorExtensions/Editor/Scripts/Utils/EditorCoroutine.cs index 0a0324b1f..d6e14b7bf 100644 --- a/ExampleTestProject/Assets/PlayFabEditorExtensions/Editor/Scripts/Utils/EditorCoroutine.cs +++ b/ExampleTestProject/Assets/PlayFabEditorExtensions/Editor/Scripts/Utils/EditorCoroutine.cs @@ -74,6 +74,7 @@ void Start() private void Stop() { EditorApplication.update -= Update; + _www.Dispose(); } private float _timeCounter = 0;