pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Matthias Otterbach <mo@otterbach.eu>
To: Jeff Janes <jeff.janes@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #15700: PG 10 vs. 11: Large increase in memory usage when selecting BYTEA data (maybe memory leak)
Date: Mon, 18 Mar 2019 19:39:32 +0100
Message-ID: <710a95e27d884885a39c8236bd51440f@otterbach.eu> (raw)
In-Reply-To: <CAMkU=1zs8cMZnFwJCeGW20wH87qcXBCd+eT7mDZL+_N+2xB4xw@mail.gmail.com>
References: <15700-8c408321a87d56bb@postgresql.org>
	<CAMkU=1zs8cMZnFwJCeGW20wH87qcXBCd+eT7mDZL+_N+2xB4xw@mail.gmail.com>

Dear Jeff, dear pgsql-bugs list,

thanks for your reply.

Am 2019-03-18 19:15, schrieb Jeff Janes:
> On Mon, Mar 18, 2019 at 7:01 AM PG Bug reporting form
> <noreply@postgresql.org> wrote:
> 
>> The Java program actually just executes "SELECT b FROM public.a" and
>> keeps
>> streaming more rows doing something with the content, also the
>> execution
>> plan for my query is fairly simple - actually it seems to be just a
>> sequential scan (with both versions).
> 
> Could you include as an attachment a complete compilable java program?
>  Including the imports, the main public class definition, etc.

Of course that is possible, you find the program attached.

You should be able to compile and execute it using the following command 
lines (maybe change the host, username and password before compilation 
as they are unfortunately hard-coded currently):

- Compilation: /your/path/to/javac TestMemoryIssue.java
- Execution: /your/path/to/java -cp 
"/your/path/to/postgresql-42.2.5.jar;." TestMemoryIssue

If it matters, I used

openjdk version "11.0.1" 2018-10-16
OpenJDK Runtime Environment 18.9 (build 11.0.1+13)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.1+13, mixed mode)

for compilation and execution of the program. But as the same program 
worked against a PG 10 database I suppose that the Java version should 
not matter.

Best regards,
Matthias Otterbach

Attachments:

TestMemoryIssue.java (text/x-c, 1.0K) download import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; public class TestMemoryIssue { public static void main(String[] args) throws Throwable { String sql = "SELECT b FROM public.a"; try (Connection connection = DriverManager.getConnection("jdbc:postgresql://127.0.0.1:5432/postgres?currentSchema=public", "username", "password")) { connection.setAutoCommit(false); try (PreparedStatement ps = connection.prepareStatement(sql)) { ps.setFetchSize(5); // we do not want to run out of Java heap space try (ResultSet rs = ps.executeQuery()) { int i = 0; while (rs.next()) { // just loop over all data, get the data and do something with it i++; byte[] b = rs.getBytes(1); if (i % 10 == 0 || b == null || b.length <= i) { System.err.println("Row " + i + ": " + (b != null ? b.length : null)); } } } } } } }

view thread (16+ messages)  latest in thread

Message-ID: <710a95e27d884885a39c8236bd51440f@otterbach.eu>
Permalink:  ../710a95e27d884885a39c8236bd51440f@otterbach.eu/
Also on:    postgresql.org/message-id/710a95e27d884885a39c8236bd51440f@otterbach.eu

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: mo@otterbach.eu, jeff.janes@gmail.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #15700: PG 10 vs. 11: Large increase in memory usage when selecting BYTEA data (maybe memory leak)
  In-Reply-To: <710a95e27d884885a39c8236bd51440f@otterbach.eu>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox