Message-ID: From: "vlsi (@vlsi)" To: "pgjdbc/pgjdbc" Date: Fri, 02 Jan 2026 20:19:59 +0000 Subject: Re: [pgjdbc/pgjdbc] issue #3902: createBlob() not closing LargeObject. In-Reply-To: References: List-Id: X-GitHub-Author-Login: vlsi X-GitHub-Comment-Id: 3706163333 X-GitHub-Comment-Type: issue_comment X-GitHub-Issue: 3902 X-GitHub-Repo: pgjdbc/pgjdbc X-GitHub-Type: comment X-GitHub-Url: https://github.com/pgjdbc/pgjdbc/issues/3902#issuecomment-3706163333 Content-Type: text/plain; charset=utf-8 @batman007db , it would be great if you could share the profiling you have. If you can reproduce the behavior with a simpler example, it would help as well. --- > profiling in jconsole, the direct memory increases As far as I understand, it should not be connected with pgjdbc. I do not think pgjdbc uses direct memory at the moment. --- You could use https://github.com/async-profiler/async-profiler to profile nativememory via `event=nativemem`. See https://github.com/async-profiler/async-profiler/blob/master/docs/ProfilerOptions.md --- Here we should use try-with-resources for `LargeObject` as well: https://github.com/pgjdbc/pgjdbc/blob/62c9805ef8606f3d38273ac69f64b14e936a0bfa/pgjdbc/src/main/java/org/postgresql/jdbc/PgPreparedStatement.java#L1258 I think the intention was "ok, we intend to use the blob as prepared statement sometime later. However, in practice closing the lob (calling `lo_close` API) does not invalidate large object oid, and it just releases a server-side handle. I guess we should better close the handle anyway as we do not access the lob after we create and populate it. However, I do not think it would impact "direct memory increases". --- @batman007db , it would be great if you could try moving `LargeObject` into try as follows (I have not tried it yet, however, it looks safe): ```java try (LargeObject lob = lom.open(oid); OutputStream outputStream = lob.getOutputStream()) { ``` However, I do not think it would impact your case though.