From 7c79b47d6170bdcc031e8c48b1e80365c00fa563 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 3 Oct 2022 21:38:05 +0200 Subject: [PATCH] Hotfix memory leak Signed-off-by: yoyosource --- .../features/tracer/show/StoredRecords.java | 6 ++++++ .../features/tracer/show/TraceShowManager.java | 13 ++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/StoredRecords.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/StoredRecords.java index ef0a449b..16601bdf 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/StoredRecords.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/StoredRecords.java @@ -53,6 +53,12 @@ public class StoredRecords { }, 1, 1); } + static void cleanup(Player player) { + isolatedTNT.forEach((region, playerListMap) -> playerListMap.remove(player)); + replayTime.forEach((region, playerIntegerMap) -> playerIntegerMap.remove(player)); + replayLoops.forEach((region, playerIntegerMap) -> playerIntegerMap.remove(player)); + } + public static void add(Region region, Record record) { records.computeIfAbsent(region, k -> new ArrayList<>()).add(record); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java index d04ee169..565db661 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java @@ -161,13 +161,12 @@ public class TraceShowManager implements Listener { @EventHandler public void onLeave(PlayerQuitEvent event) { Region region = Region.getRegion(event.getPlayer().getLocation()); - if (region.isGlobal()) { - return; + if (!region.isGlobal()) { + Map> regionalShowModes = showModes.get(region); + if (regionalShowModes != null) { + regionalShowModes.remove(event.getPlayer()); + } } - Map> regionalShowModes = showModes.get(region); - if (regionalShowModes == null) { - return; - } - regionalShowModes.remove(event.getPlayer()); + StoredRecords.cleanup(event.getPlayer()); } }