Skip to content

Commit

Permalink
Gated PartUpwardCache leaks logging behind a specific #DEFINE to avoi…
Browse files Browse the repository at this point in the history
…d being spammed in debug builds
  • Loading branch information
gotmachine committed Apr 5, 2024
1 parent 5836871 commit 28c174d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions KSPCommunityFixes/Performance/MemoryLeaks.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using CommNet;
//#define LOG_PART_UPWARD_CACHE_LEAKS

using CommNet;
using HarmonyLib;
using KSP.UI;
using KSP.UI.Screens;
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 28c174d

Please sign in to comment.