Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id C36FB1FC9B63 for ; Mon, 13 Feb 2012 09:28:03 -0400 (AST) Received: from mail-bk0-f46.google.com ([209.85.214.46]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Rwvwm-0000vI-Pu for pgsql-jdbc@postgresql.org; Mon, 13 Feb 2012 13:28:03 +0000 Received: by bkcjm19 with SMTP id jm19so4530405bkc.19 for ; Mon, 13 Feb 2012 05:27:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type; bh=gf2qhNluAxSW9BAoUZGlLHnCP4s6jnwWOjn9IJrdcwM=; b=GplR97TEyHfF4lxmsGJW55dQD+XIlWQaet/HtgTCnd577p67i90CqeB0iNQ291KthW 6R4ViU9SMvZGvyyVvahLevTqhZNgY4F2XmDCCZnmv+Ty3ORDXkAIeTQuep6/MXgFqJ2I DVMgrd/kIQwR1lqmMj2ie1bRaKYn+gXEIxhZo= Received: by 10.205.117.4 with SMTP id fk4mr4566662bkc.11.1329139667585; Mon, 13 Feb 2012 05:27:47 -0800 (PST) Received: from [10.64.1.26] ([94.45.140.16]) by mx.google.com with ESMTPS id t17sm46285308bke.6.2012.02.13.05.27.45 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 13 Feb 2012 05:27:45 -0800 (PST) Message-ID: <4F390FF2.2040500@gmail.com> Date: Mon, 13 Feb 2012 15:28:18 +0200 From: Vitalii Tymchyshyn User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.26) Gecko/20120131 Lightning/1.0b2 Thunderbird/3.1.18 MIME-Version: 1.0 To: Imran CC: Dave Cramer , pgsql-jdbc@postgresql.org Subject: Re: non-trivial finalize() on AbstractJdbc2Statement References: In-Reply-To: Content-Type: multipart/alternative; boundary="------------050805080900030104070603" X-Pg-Spam-Score: -1.3 (-) X-Archive-Number: 201202/40 X-Sequence-Number: 22693 This is a multi-part message in MIME format. --------------050805080900030104070603 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hello. While it would be better to handle resource closing with reference queues, are you sure your client does not leave resources unclosed? As for me, driver in finalize should do only work not done because of close not have been called correctly. In other words, your situation may be an indication of close not been called, and so driver does required work in finalize, so saturating finalize thread. Best regards, Vitalii Tymchyshyn 13.02.12 15:02, Imran ???????(??): > Hi Dave > > Thanks for your response. I agree that this might not be widespread. > And I haven't seen much mentions around this problem (hitting GC > issues due to non-trivial finalize() methods) reported (based on my > google searches). However, I guess the existence of it does provide > the opportunity for this to happen as we've noticed. IMHO, encouraging > clients to use the api as recommended (i.e. closing resources once > they are done with them) is better than the driver allowing > opportunity for bad things to happen. Or perhaps the driver caters to > this kind of situation using WeakReference as oppose to using a > non-trivial finalize(). > > What are your thoughts? > > Cheers > -- Imran > > On Mon, Feb 13, 2012 at 12:09 PM, Dave Cramer > wrote: > > Well this is a typical which is worse case scenario. People leaking > resources because they don't explicitly close them, or your case ? I'm > not sure which is worse. > > Given that the driver is being used in many very high throughput sites > without this problem, I'm curious as to why nobody else has complained > > Dave Cramer > > dave.cramer(at)credativ(dot)ca > http://www.credativ.ca > > > > On Fri, Feb 10, 2012 at 12:39 PM, Imran > wrote: > > Hello > > > > We've been having OOM errors in our applications through GC > overhead limits > > under heave load resources running queries. Inspecting the heap > dump, it > > appears that the finalizer queue is taken up most of the heap > space. Almost > > all of the the finalizer objects I've seen seem to have a > > jdbc3PreparedStatement object in it. Going through the source > code of the > > driver I see that the 'AbstractJdbc2Statement' has a non-trivial > finalize > > method. I guess this explains why these objects end up in the > finalizer > > queue. Can I clarify the need to having this finalize() method > here? It > > seems to be calling the close() method of the statement which I > would have > > thought is the responsibility of the client building a Statement > object. Is > > there any chance this can be dropped so we don't see these > objects ending up > > in the finalizer queue under heavy load and the jvm running out > of memory > > before the GC threads gets around to 'actually' reclaim the memory? > > > > Also we are using postgres 9.0.4 and the 8.3-604.jdbc3 version > of the > > postgresql jdbc driver. > > > > Cheers > > -- Imran > > --------------050805080900030104070603 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hello.

While it would be better to handle resource closing with reference queues, are you sure your client does not leave resources unclosed? As for me, driver in finalize should do only work not done because of close not have been called correctly.  In other words, your situation may be an indication of close not been called, and so driver does required work in finalize, so saturating finalize thread.

Best regards, Vitalii Tymchyshyn

13.02.12 15:02, Imran написав(ла):
Hi Dave

Thanks for your response. I agree that this might not be widespread. And I haven't seen much mentions around this problem (hitting GC issues due to non-trivial finalize() methods) reported (based on my google searches). However, I guess the existence of it does provide the opportunity for this to happen as we've noticed. IMHO, encouraging clients to use the api as recommended (i.e. closing resources once they are done with them) is better than the driver allowing opportunity for bad things to happen. Or perhaps the driver caters to this kind of situation using WeakReference as oppose to using a non-trivial finalize(). 

What are your thoughts?

Cheers
-- Imran  

On Mon, Feb 13, 2012 at 12:09 PM, Dave Cramer <pg@fastcrypt.com> wrote:
Well this is a typical which is worse case scenario. People leaking
resources because they don't explicitly close them, or your case ? I'm
not sure which is worse.

Given that the driver is being used in many very high throughput sites
without this problem, I'm curious as to why nobody else has complained

Dave Cramer

dave.cramer(at)credativ(dot)ca
http://www.credativ.ca



On Fri, Feb 10, 2012 at 12:39 PM, Imran <imranbohoran@gmail.com> wrote:
> Hello
>
> We've been having OOM errors in our applications through GC overhead limits
> under heave load resources running queries. Inspecting the heap dump, it
> appears that the finalizer queue is taken up most of the heap space. Almost
> all of the the finalizer objects I've seen seem to have a
> jdbc3PreparedStatement object in it. Going through the source code of the
> driver I see that the 'AbstractJdbc2Statement' has a non-trivial finalize
> method. I guess this explains why these objects end up in the finalizer
> queue. Can I clarify the need to having this finalize() method here? It
> seems to be calling the close() method of the statement which I would have
> thought is the responsibility of the client building a Statement object. Is
> there any chance this can be dropped so we don't see these objects ending up
> in the finalizer queue under heavy load and the jvm running out of memory
> before the GC threads gets around to 'actually' reclaim the memory?
>
> Also we are using postgres 9.0.4 and the 8.3-604.jdbc3 version of the
> postgresql jdbc driver.
>
> Cheers
> -- Imran


--------------050805080900030104070603--