发现了位于Native堆上严重的内存泄露

This commit is contained in:
2025-10-10 01:01:36 +08:00
parent 560b8f825c
commit 5539431a5b
6 changed files with 98 additions and 16 deletions

View File

@@ -278,9 +278,8 @@ namespace Demo.Game
private bool IsScrollTimeline = false;
#if UNITY_EDITOR
public ProfilerMarker s_PreparePerfMarkerForSetSongCurrentTime = new(nameof(GameController) + "RuntimeForSetSongCurrentTime");
public ProfilerMarker s_PreparePerfMarker = new(nameof(GameController) + "Runtime");
#endif
private void Update()
{
@@ -294,15 +293,15 @@ namespace Demo.Game
// TODO : 修正这个逻辑,这个逻辑是反常的
if (MainAudio.IsPlaying())
{
s_PreparePerfMarkerForSetSongCurrentTime.Begin();
SetSongCurrentTime(CurrentTime);
s_PreparePerfMarkerForSetSongCurrentTime.End();
MainObject.ScriptUpdate(CurrentTime, deltaTime, ScriptableObject.TickType.Update);
}
if (IsMain == false)
return;
#if UNITY_EDITOR
s_PreparePerfMarker.Begin(this);
#endif
#if UNITY_EDITOR
if (Keyboard.current[Key.LeftShift].isPressed)
#else
@@ -349,9 +348,7 @@ namespace Demo.Game
}
}
}
#if UNITY_EDITOR
s_PreparePerfMarker.End();
#endif
}
public IEnumerator GameExit()

View File

@@ -647,8 +647,8 @@ namespace Demo
public void EnableScript(string sourcePath, string scriptPath, string scriptType, ScriptableObject parent)
{
#if UNITY_EDITOR
s_PreparePerfMarker = new(scriptPath);
#if UNITY_EDITOR||true
s_PreparePerfMarker = new(ScriptName);
#endif
if (isEnableScript)
{
@@ -705,7 +705,7 @@ namespace Demo
public string ScriptPath;
public string ScriptTypename;
#if UNITY_EDITOR
#if UNITY_EDITOR||true
public ProfilerMarker s_PreparePerfMarker;
#endif
public ScriptableObject Parent;
@@ -1129,7 +1129,7 @@ namespace Demo
return;
if (gameObject.activeInHierarchy == false)
return;
#if UNITY_EDITOR
#if UNITY_EDITOR||true
s_PreparePerfMarker.Begin(this);
#endif
if (tickType == TickType.Reset)
@@ -1148,7 +1148,7 @@ namespace Demo
{
child.ScriptUpdate(currentTime, deltaTime, tickType);
}
#if UNITY_EDITOR
#if UNITY_EDITOR||true
s_PreparePerfMarker.End();
#endif
}