From 9962d3c7f8755db795392f6e756307bde11c6590 Mon Sep 17 00:00:00 2001 From: Ben Liblit Date: Mon, 4 Sep 2023 14:51:31 -0400 Subject: [PATCH] Avoid memory leak for thread-local values Setting the thread-local value to `null` is not the same as removing it. The former retains an entry mapping the current thread's value to `null` in a hidden global map. The latter removes the current thread's entry entirely. --- shrike/src/main/java/com/ibm/wala/shrike/cg/Runtime.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shrike/src/main/java/com/ibm/wala/shrike/cg/Runtime.java b/shrike/src/main/java/com/ibm/wala/shrike/cg/Runtime.java index 96df849d6f..c3466f4740 100644 --- a/shrike/src/main/java/com/ibm/wala/shrike/cg/Runtime.java +++ b/shrike/src/main/java/com/ibm/wala/shrike/cg/Runtime.java @@ -124,7 +124,7 @@ public static String bashToDescriptor(String className) { } public static void execution(String klass, String method, Object receiver) { - runtime.currentSite.set(null); + runtime.currentSite.remove(); if (runtime.filter == null || !runtime.filter.contains(bashToDescriptor(klass))) { if (runtime.output != null) { String caller = runtime.callStacks.get().peek(); @@ -183,7 +183,7 @@ public static void pop() { } } - runtime.currentSite.set(null); + runtime.currentSite.remove(); } }