From 28c174dbcbe881083da94a5528dd669a79b4ae47 Mon Sep 17 00:00:00 2001 From: gotmachine <24925209+gotmachine@users.noreply.github.com> Date: Fri, 5 Apr 2024 12:23:31 +0200 Subject: [PATCH] Gated PartUpwardCache leaks logging behind a specific #DEFINE to avoid being spammed in debug builds --- KSPCommunityFixes/Performance/MemoryLeaks.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/KSPCommunityFixes/Performance/MemoryLeaks.cs b/KSPCommunityFixes/Performance/MemoryLeaks.cs index cae58d7..c10393b 100644 --- a/KSPCommunityFixes/Performance/MemoryLeaks.cs +++ b/KSPCommunityFixes/Performance/MemoryLeaks.cs @@ -1,4 +1,6 @@ -using CommNet; +//#define LOG_PART_UPWARD_CACHE_LEAKS + +using CommNet; using HarmonyLib; using KSP.UI; using KSP.UI.Screens; @@ -741,7 +743,7 @@ static void Part_OnDestroy_Postfix(Part __instance) __instance.parent = __instance.potentialParent = null; __instance.internalModel = null; -#if DEBUG +#if LOG_PART_UPWARD_CACHE_LEAKS if (FlightGlobals.objectToPartUpwardsCache.Values.Contains(__instance)) { Debug.LogError($"Destroying part {__instance.GetInstanceID()} while it's still in the objectToPartUpwardsCache");