zymap commented on code in PR #3417: URL: https://github.com/apache/bookkeeper/pull/3417#discussion_r929913309
########## bookkeeper-server/src/main/java/org/apache/bookkeeper/util/collections/ConcurrentLongHashMap.java: ########## @@ -507,7 +507,11 @@ private V remove(long key, Object value, int keyHash) { } finally { if (autoShrink && size < resizeThresholdBelow) { try { - int newCapacity = alignToPowerOfTwo((int) (capacity / shrinkFactor)); + // Shrinking must at least ensure initCapacity, + // so as to avoid frequent shrinking and expansion near initCapacity, + // frequent shrinking and expansion, + // additionally opened arrays will consume more memory and affect GC + int newCapacity = Math.max(alignToPowerOfTwo((int) (capacity / shrinkFactor)), initCapacity); Review Comment: Thanks for your detailed explanation! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@bookkeeper.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org