From 69205182cdcb088457328eb53bf3edafa57fd116 Mon Sep 17 00:00:00 2001 From: hadashiA Date: Wed, 25 Mar 2026 15:48:29 +0900 Subject: [PATCH] Fix memory leak caused by unreleased static references --- Assets/UniGLTF/Runtime/UniGLTF/RuntimeGltfInstance.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Assets/UniGLTF/Runtime/UniGLTF/RuntimeGltfInstance.cs b/Assets/UniGLTF/Runtime/UniGLTF/RuntimeGltfInstance.cs index 6f4374687..b4c6417eb 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/RuntimeGltfInstance.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/RuntimeGltfInstance.cs @@ -255,9 +255,10 @@ namespace UniGLTF } } - static Dictionary> PoseMap = new(); + static readonly Dictionary> PoseMap = new(); + public static IReadOnlyDictionary SafeGetInitialPose( - Transform root, bool useCache = true) + Transform root, bool useCache = false) { if (useCache && PoseMap.TryGetValue(root, out var pose)) { @@ -278,7 +279,10 @@ namespace UniGLTF } // add cache - PoseMap.Add(root, pose); + if (useCache) + { + PoseMap.Add(root, pose); + } return pose; }