This is an automated email from the ASF dual-hosted git repository. morningman pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new 529586c7781 [fix](mem leak) fe non_heap mem leak while use jdbc catalog (#45806) 529586c7781 is described below commit 529586c778114956658b8d7aca8b2b9bd17bd2f7 Author: camby <camby...@tencent.com> AuthorDate: Thu Dec 26 10:48:20 2024 +0800 [fix](mem leak) fe non_heap mem leak while use jdbc catalog (#45806) ### What problem does this PR solve? Issue Number: close https://github.com/apache/doris/issues/45609 --- .../apache/doris/datasource/jdbc/client/JdbcClient.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcClient.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcClient.java index 51f55ea24ba..f139dde5af2 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcClient.java +++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcClient.java @@ -48,6 +48,7 @@ import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; import java.util.function.Consumer; @Getter @@ -56,6 +57,8 @@ public abstract class JdbcClient { private static final int HTTP_TIMEOUT_MS = 10000; protected static final int JDBC_DATETIME_SCALE = 6; + private static final Map<URL, ClassLoader> classLoaderMap = new ConcurrentHashMap<>(); + private String catalogName; protected String dbType; protected String jdbcUser; @@ -147,11 +150,16 @@ public abstract class JdbcClient { } } - private void initializeClassLoader(JdbcClientConfig config) { + private synchronized void initializeClassLoader(JdbcClientConfig config) { try { URL[] urls = {new URL(JdbcResource.getFullDriverUrl(config.getDriverUrl()))}; - ClassLoader parent = getClass().getClassLoader(); - this.classLoader = URLClassLoader.newInstance(urls, parent); + if (classLoaderMap.containsKey(urls[0])) { + this.classLoader = classLoaderMap.get(urls[0]); + } else { + ClassLoader parent = getClass().getClassLoader(); + this.classLoader = URLClassLoader.newInstance(urls, parent); + classLoaderMap.put(urls[0], this.classLoader); + } } catch (MalformedURLException e) { throw new RuntimeException("Error loading JDBC driver.", e); } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org