From: Not Zed Date: Sun, 26 Jan 2020 07:40:40 +0000 (+1030) Subject: Set the hashtable loadfactor to 1 rather than 2. X-Git-Url: https://code.zedzone.au/cvs?a=commitdiff_plain;h=12839fe0996e6f0f0504af546e28f5d8bced66e0;p=zcl Set the hashtable loadfactor to 1 rather than 2. Added some debug code to try to flush everything unreachable or manually retired. --- diff --git a/src/notzed.zcl/classes/api/Native.java b/src/notzed.zcl/classes/api/Native.java index 4260da2..db0dfbe 100644 --- a/src/notzed.zcl/classes/api/Native.java +++ b/src/notzed.zcl/classes/api/Native.java @@ -866,6 +866,27 @@ public class Native { } } + public static void debugFlushAll() { + for (int i=0;i<3;i++) { + try { + System.gc(); + Thread.sleep(100); + } catch (InterruptedException x) { + } + CHandle stale = (CHandle) references.poll(); + while (stale != null) { + try { + synchronized (map) { + map.remove(stale.p); + } + stale.release(); + } catch (Throwable ex) { + } + stale = (CHandle) references.poll(); + } + } + } + public static void debugDumpReachable(String title) { synchronized (map) { System.out.println(title); @@ -933,7 +954,7 @@ public class Native { } public void putAlways(CHandle h) { - if (size > table.length * 2) + if (size > table.length) resize(table.length * 2); int i = h.hashCode() & mask;