You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2026/08/29 09:11:31 UTC

(sis) branch geoapi-4.0 updated: Remove the call to `System.gc()` before to check whether JDBC resource can be closed. It may cause JDBC resources to be kept for a longer time, but `System.gc()` add too much overhead in applications with large heap.

This is an automated email from the ASF dual-hosted git repository.

asf-gitbox-commits pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git


The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
     new 5643725a77 Remove the call to `System.gc()` before to check whether JDBC resource can be closed. It may cause JDBC resources to be kept for a longer time, but `System.gc()` add too much overhead in applications with large heap.
5643725a77 is described below

commit 5643725a772255127b66d7a4924cb8b80feb8073
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Sat Aug 29 11:49:13 2026 +0900

    Remove the call to `System.gc()` before to check whether JDBC resource can be closed.
    It may cause JDBC resources to be kept for a longer time, but `System.gc()` add too
    much overhead in applications with large heap.
    
    https://issues.apache.org/jira/browse/SIS-637
---
 .../sis/referencing/factory/ConcurrentAuthorityFactory.java       | 8 ++++++--
 .../org/apache/sis/referencing/factory/sql/EPSGDataAccess.java    | 6 +++++-
 .../main/org/apache/sis/referencing/factory/sql/EPSGFactory.java  | 4 +---
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java
index b90fdccd86..32cf7fb30d 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/ConcurrentAuthorityFactory.java
@@ -131,14 +131,14 @@ public abstract class ConcurrentAuthorityFactory<DAO extends GeodeticAuthorityFa
      *
      * @see #isDefault(Class)
      */
-    private final Map<Class<?>,Boolean> inherited = new IdentityHashMap<>();
+    private final Map<Class<?>, Boolean> inherited = new IdentityHashMap<>();
 
     /**
      * The pool of cached objects. Keys are (type, code) tuples; the type is stored because the same code
      * may be used for different kinds of objects. Values are usually instances of {@link IdentifiedObject},
      * but can also be instances of unrelated types such as {@link Extent}.
      */
-    private final Cache<Key,Object> cache;
+    private final Cache<Key, Object> cache;
 
     /**
      * The pool of objects identified by {@link Finder#find(IdentifiedObject)}.
@@ -754,6 +754,10 @@ public abstract class ConcurrentAuthorityFactory<DAO extends GeodeticAuthorityFa
      *   <li>release the Data Access Object.</li>
      * </ol>
      *
+     * For some implementations, the returned set maintains a live connection to a database.
+     * See {@link org.apache.sis.referencing.factory.sql.EPSGDataAccess#getAuthorityCodes(Class)}
+     * for more information.
+     *
      * @param  type  the spatial reference objects type (e.g. {@code ProjectedCRS.class}).
      * @return the set of authority codes for spatial reference objects of the given type.
      *         If this factory does not contains any object of the given type, then this method returns an empty set.
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
index 2f2c237172..44af472153 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
@@ -3863,7 +3863,11 @@ search: try (ResultSet result = executeMetadataQuery("Deprecation",
         boolean can = true;
         SQLException error = null;
         if (!authorityCodes.isEmpty()) {
-            System.gc();                // For cleaning as much weak references as we can before we check them.
+            /*
+             * We could invoke `System.gc()` here for clearing more weak references,
+             * which is needed for determining whether we can close the connection.
+             * But is causes too much overload in application with large heap.
+             */
             final Iterator<CloseableReference> it = authorityCodes.values().iterator();
             while (it.hasNext()) {
                 final CloseableReference reference = it.next();
diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/EPSGFactory.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/EPSGFactory.java
index 70fcbd36f2..49d9e48b42 100644
--- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/EPSGFactory.java
+++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/factory/sql/EPSGFactory.java
@@ -19,7 +19,6 @@ package org.apache.sis.referencing.factory.sql;
 import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
-import java.util.concurrent.TimeUnit;
 import java.sql.Connection;
 import java.sql.DatabaseMetaData;
 import java.sql.SQLException;
@@ -186,7 +185,7 @@ public class EPSGFactory extends ConcurrentAuthorityFactory<EPSGDataAccess> impl
      * Creates a factory using the given configuration. The properties recognized by this constructor
      * are listed in the table below. Any property not listed below will be ignored by this constructor.
      * All properties are optional and can {@code null} or omitted, in which case default values are used.
-     * Those default values are implementation-specific and may change in any future SIS version.
+     * Those default values are implementation-specific and may change in any future <abbr>SIS</abbr> version.
      *
      * <table class="sis">
      *  <caption>Recognized properties</caption>
@@ -295,7 +294,6 @@ public class EPSGFactory extends ConcurrentAuthorityFactory<EPSGDataAccess> impl
         crsFactory   = c.getCRSFactory();
         copFactory   = c.getCoordinateOperationFactory();
         mtFactory    = c.getMathTransformFactory();
-        super.setTimeout(10, TimeUnit.SECONDS);
     }
 
     /**