From cfc635a7a317d4243a48bdd89cfa58cb7b52cae4 Mon Sep 17 00:00:00 2001 From: "yevgen.pavlenko" Date: Tue, 18 Jun 2024 13:58:58 +0300 Subject: [PATCH] Don't exit OldDeletedEntriesCleanupThread until a startup delay. Closes https://github.com/OpenHFT/Chronicle-Map/issues/310 --- .../chronicle/map/OldDeletedEntriesCleanupThread.java | 5 +++-- src/test/java/net/openhft/chronicle/map/MemoryLeaksTest.java | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/openhft/chronicle/map/OldDeletedEntriesCleanupThread.java b/src/main/java/net/openhft/chronicle/map/OldDeletedEntriesCleanupThread.java index af294b8b09..126384c6a8 100644 --- a/src/main/java/net/openhft/chronicle/map/OldDeletedEntriesCleanupThread.java +++ b/src/main/java/net/openhft/chronicle/map/OldDeletedEntriesCleanupThread.java @@ -114,8 +114,9 @@ private static int[] inversePermutation(int[] permutation) { public void run() { throwExceptionIfClosed(); - if (System.currentTimeMillis() - startTime < 1_000) - return; + long runningTime = System.currentTimeMillis() - startTime; + if (runningTime < 1_000) + sleepMillis(1_000 - runningTime); while (!shutdown) { int nextSegmentIndex; diff --git a/src/test/java/net/openhft/chronicle/map/MemoryLeaksTest.java b/src/test/java/net/openhft/chronicle/map/MemoryLeaksTest.java index a3acdb151f..443785a39c 100644 --- a/src/test/java/net/openhft/chronicle/map/MemoryLeaksTest.java +++ b/src/test/java/net/openhft/chronicle/map/MemoryLeaksTest.java @@ -69,6 +69,7 @@ public MemoryLeaksTest(String testType, boolean replicated, boolean persisted, b builder = ChronicleMap .of(IntValue.class, String.class).constantKeySizeBySample(Values.newHeapInstance(IntValue.class)) .valueReaderAndDataAccess(new CountedStringReader(this), new StringUtf8DataAccess()); + builder.cleanupRemovedEntries(false); if (replicated) builder.replication((byte) 1); builder.entries(1).averageValueSize(10);