From: Dave Cramer <Dave@micro-automation.net>
To: 'Rainer Mager' <rmager@vgkk.com>
To: 'Bruce Momjian' <pgman@candle.pha.pa.us>
Cc: 'PostgreSQL jdbc list' <pgsql-jdbc@postgresql.org>
Subject: RE: Re: [ADMIN] High memory usage [PATCH]
Date: Fri, 22 Jun 2001 10:34:07 -0400
Message-ID: <000001c0fb28$65546ff0$0201a8c0@INSPIRON> (raw)
In-Reply-To: <NEBBJBCAFMMNIHGDLFKGIELIEFAA.rmager@vgkk.com>
I am going to have a look at the spec in more detail to see how they
expect the driver to be used within threads
I am in a similar situation wrt using the driver in server and will
check if the memory usage is better.
Dave
-----Original Message-----
From: pgsql-jdbc-owner@postgresql.org
[mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Rainer Mager
Sent: June 22, 2001 12:56 AM
To: Dave Cramer; Bruce Momjian
Cc: PostgreSQL jdbc list
Subject: RE: [JDBC] Re: [ADMIN] High memory usage [PATCH]
Good questions, I'll answer what I can...
> 1) what is the problem that this is trying to solve, I assume from the
> subject that it is some sort of high memory usage?
Yes it involves memory usage and a memory leak. Basically, the way the
code
was before the patch, each instantiation of a PreparedStatement created
2
new ThreadLocal objects. According to Sun's Javadocs, these objects are
not
freed until the thread is completed. For a single thread app or main
thread
of an application (in our case a server) the thread NEVER goes away.
Therefore these ThreadLocal objects just keep adding up and using
memory,
forever.
The patch removes the use of these ThreadLocals.
> 2) I am trying to understand how a statement would ever be used
> by more than
> one thread at a time? I would think that it would be impossible to
share
> statements across threads.
This I can't really answer. The code appeared to be written to be thread
safe so I attempted to continue that. Whether thread safe for a
Statement is
necessary or not I can't directly say. Although, I agree with you, I
can't
imagine a need to use a single Statement in multiple threads.
> 3) The double locking method used is alledgedly unsafe on SMP machines
> http://www.javaworld.com/javaworld/jw-02-2001/jw-0209-double_p.html.
Interesting. I wasn't aware of this. If question #2 is answered such
that
thread safe isn't necessary, then this problem goes away pretty easily.
If
thread safety is needed then this would have to be rewritten, I can look
into doing this if you like.
> Dave
--Rainer
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: Dave@micro-automation.net, rmager@vgkk.com, pgman@candle.pha.pa.us, pgsql-jdbc@postgresql.org
Subject: Re: [ADMIN] High memory usage [PATCH]
In-Reply-To: <000001c0fb28$65546ff0$0201a8c0@INSPIRON>
References: <NEBBJBCAFMMNIHGDLFKGIELIEFAA.rmager@vgkk.com> <000001c0fb28$65546ff0$0201a8c0@INSPIRON>
* 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