From a3db117d9ff3a030f632f83c5847e57a8cd47253 Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Thu, 23 May 2024 13:31:05 +0200 Subject: [PATCH] [jOOQ/jOOQ#16315] Memory leak in DefaultCacheProvider when large amounts of arbitrary projections are mapped with DefaultRecordMapper --- .../main/java/org/jooq/impl/DefaultCacheProvider.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/jOOQ/src/main/java/org/jooq/impl/DefaultCacheProvider.java b/jOOQ/src/main/java/org/jooq/impl/DefaultCacheProvider.java index 0dacb15ffb..98b181adb1 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DefaultCacheProvider.java +++ b/jOOQ/src/main/java/org/jooq/impl/DefaultCacheProvider.java @@ -48,8 +48,7 @@ import org.jooq.CacheContext; import org.jooq.CacheProvider; /** - * A default implementation producing a {@link ConcurrentHashMap} in most cases, - * or a synchronized LRU cache where appropriate. + * A default implementation a synchronized LRU cache where appropriate. * * @author Lukas Eder */ @@ -58,14 +57,12 @@ final class DefaultCacheProvider implements CacheProvider { @Override public Map provide(CacheContext ctx) { switch (ctx.cacheType()) { - - // TODO: Is there a better implementation than wrapping LinkedHashMap - // in synchronizedMap(), i.e. one that does not use a monitor? case CACHE_PARSING_CONNECTION: - return synchronizedMap(new LRUCache<>(defaultIfNull(ctx.settings().getCacheParsingConnectionLRUCacheSize(), 8912))); + return synchronizedMap(new LRUCache<>(defaultIfNull(ctx.settings().getCacheParsingConnectionLRUCacheSize(), 8192))); + // [#16696] Resizing this will be possible starting from jOOQ 3.20 default: - return new ConcurrentHashMap<>(); + return synchronizedMap(new LRUCache<>(8192)); } } }