Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pThgz-00021h-BE for pgsql-jdbc-commits@arkaria.postgresql.org; Sun, 19 Feb 2023 11:17:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pThgt-0001j5-MQ for pgsql-jdbc-commits@arkaria.postgresql.org; Sun, 19 Feb 2023 11:17:11 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pThXK-0008AE-N9; Sun, 19 Feb 2023 11:07:18 +0000 Received: from out-25.smtp.github.com ([192.30.252.208]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pThXI-0005zB-Bs; Sun, 19 Feb 2023 11:07:18 +0000 Received: from github.com (hubbernetes-node-fe9d649.ash1-iad.github.net [10.56.14.62]) by smtp.github.com (Postfix) with ESMTPA id 86840840258; Sun, 19 Feb 2023 03:07:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=github.com; s=pf2014; t=1676804834; bh=Xa+ftcOC22W4wSmMMiS6z4yGiBMQYHAoCAUGMyzW5TU=; h=Date:From:To:Subject:From; b=k9NfANad4lL6dRStIjVOjMeP2uZT74v8iByhM/nXpknA70eK8EgOXbF1hshXZGmiw o8j28fFjwPykrPeD/9PGjxud5Wx8U3txssKPZL6Enczdhu+WUXG0lNRu9DRuqRx3ei N7ROg1Cuv+OZ5nC1hMlLt/1J0nsuROhKMmdV+U6Y= Date: Sun, 19 Feb 2023 03:07:14 -0800 From: Vladimir Sitnikov To: pgsql-jdbc@lists.postgresql.org, pgsql-jdbc-commits@lists.postgresql.org Message-ID: Subject: [pgjdbc/pgjdbc] c40855: fix: reduce memory overhead of .finalize() methods... Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Approved: 58GruLoMopuc X-GitHub-Recipient-Address: pgsql-jdbc@lists.postgresql.org,pgsql-jdbc-commits@lists.postgresql.org X-Auto-Response-Suppress: All List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Branch: refs/heads/master Home: https://github.com/pgjdbc/pgjdbc Commit: c40855f14b1601c85222084d949856efbce9bbcc https://github.com/pgjdbc/pgjdbc/commit/c40855f14b1601c85222084d949856efbce9bbcc Author: Vladimir Sitnikov Date: 2023-02-19 (Sun, 19 Feb 2023) Changed paths: M pgjdbc/src/main/java/org/postgresql/core/QueryExecutor.java M pgjdbc/src/main/java/org/postgresql/core/QueryExecutorBase.java A pgjdbc/src/main/java/org/postgresql/core/QueryExecutorCloseAction.java M pgjdbc/src/main/java/org/postgresql/core/v3/QueryExecutorImpl.java M pgjdbc/src/main/java/org/postgresql/core/v3/SimpleParameterList.java M pgjdbc/src/main/java/org/postgresql/jdbc/PgConnection.java A pgjdbc/src/main/java/org/postgresql/jdbc/PgConnectionFinalizeAction.java M pgjdbc/src/main/java/org/postgresql/util/StreamWrapper.java A pgjdbc/src/main/java/org/postgresql/util/StreamWrapperFinalizeAction.java M pgjdbc/src/test/java/org/postgresql/test/jdbc2/CopyTest.java Log Message: ----------- fix: reduce memory overhead of .finalize() methods in PgConnection and StreamWrapper (#2817) Previously, an abandoned PgConnection could retain a significant amount of heap. Now the bare minimum is moved to a separate class, so the abandoned connections can be removed from the heap earlier. This does not remove the use of `.finalize()`, and it only reduces the amount of retained heap memory. Fixes https://github.com/pgjdbc/pgjdbc/issues/1431 Fixes https://github.com/pgjdbc/pgjdbc/issues/1360