From 5485af23b421d1a47bed3770f99523a67f03f7f0 Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期四, 11 四月 2024 18:56:19 +0800
Subject: [PATCH] 0312 修复加载问题,优化内存释放

---
 Assets/Launch/ResourcesModel.cs |    6 +++---
 Assets/Launch/LoadDll.cs        |    8 +++-----
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/Assets/Launch/LoadDll.cs b/Assets/Launch/LoadDll.cs
index 4855112..27bb689 100644
--- a/Assets/Launch/LoadDll.cs
+++ b/Assets/Launch/LoadDll.cs
@@ -111,8 +111,7 @@
                     if (asset == "Assembly-CSharp.dll.bytes")
                     {
                         assetData = new byte[www.downloadHandler.data.Length - 3];
-                        Array.Copy(assetData, 3, www.downloadHandler.data, 0, www.downloadHandler.data.Length);
-
+                        Array.Copy(www.downloadHandler.data, 3, assetData, 0, assetData.Length);
                     }
                     else
                     { 
@@ -145,9 +144,8 @@
             {
                 if (aotDllName == "Assembly-CSharp.dll.bytes")
                     continue;
-                byte[] dllBytes = ReadBytesFromStreamingAssets(aotDllName);
                 // 鍔犺浇assembly瀵瑰簲鐨刣ll锛屼細鑷姩涓哄畠hook銆備竴鏃ot娉涘瀷鍑芥暟鐨刵ative鍑芥暟涓嶅瓨鍦紝鐢ㄨВ閲婂櫒鐗堟湰浠g爜
-                LoadImageErrorCode err = RuntimeApi.LoadMetadataForAOTAssembly(dllBytes, mode);
+                LoadImageErrorCode err = RuntimeApi.LoadMetadataForAOTAssembly(ReadBytesFromStreamingAssets(aotDllName), mode);
                 Debug.Log($"LoadMetadataForAOTAssembly:{aotDllName}. mode:{mode} ret:{err}");
             }
         }
@@ -157,7 +155,7 @@
 #if !UNITY_EDITOR
         LoadMetadataForAOTAssemblies();
         _hotUpdateAss = Assembly.Load(ReadBytesFromStreamingAssets("Assembly-CSharp.dll.bytes"));
-        s_assetDatas.Clear();
+        s_assetDatas = null;
 #else
             if (_hotUpdateAss == null)
                 _hotUpdateAss = System.AppDomain.CurrentDomain.GetAssemblies().First(a => a.GetName().Name == "Assembly-CSharp");
diff --git a/Assets/Launch/ResourcesModel.cs b/Assets/Launch/ResourcesModel.cs
index c5ccb91..8e50e6e 100644
--- a/Assets/Launch/ResourcesModel.cs
+++ b/Assets/Launch/ResourcesModel.cs
@@ -157,8 +157,8 @@
         {
             spriteBundle?.Unload(true);  //true瀹屽叏鍗歌浇锛屾洿鏂板悗閲嶆柊鍔犺浇
             prefabBundle?.Unload(true);
-            assetVersions.Clear();
-            localAssetVersions.Clear();
+            assetVersions = null;
+            localAssetVersions = null;
             Debug.Log("鎻愬墠ResourcesModel.Destroy璧勬簮");
         }
 
@@ -439,7 +439,7 @@
                     if (isOK)
                         InitLocalLogicbytes(value);
                     else
-                        Debug.LogError("InitTable logicbytes error");
+                        Debug.LogWarning("InitTable logicbytes error");
                 }, StreamingAssetPath));
             }
         }

--
Gitblit v1.8.0