pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Vitalii Tymchyshyn <tivv00@gmail.com>
To: Imran <imranbohoran@gmail.com>
Cc: Dave Cramer <pg@fastcrypt.com>
Cc: Kevin Grittner <Kevin.Grittner@wicourts.gov>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: non-trivial finalize() on AbstractJdbc2Statement
Date: Wed, 15 Feb 2012 14:50:42 +0200
Message-ID: <4F3BAA22.1040103@gmail.com> (raw)
In-Reply-To: <CAG6o=AELXcR5XHt3s=1NLx3sRDnhRjtSj2yWFbL7O+KR2Qo2FQ@mail.gmail.com>
References: <CAG6o=AHE4yfi5E6Ec2FBE=0o3f=QPbN54Fr_HZAysc+m7nJ-Pw@mail.gmail.com>
	<CADK3HH+rKyg+ss71B0J9AaaKjQduHUj6MYrVaB_qmDaWmPsNew@mail.gmail.com>
	<CAG6o=AFRjZAEVi_+LSgYSszE669gEjcNBYn6qcHNgZeGMWmHxA@mail.gmail.com>
	<4F390FF2.2040500@gmail.com>
	<CAG6o=AGivBfOaytb+0PA2Wp-PMpiYZWyxUNxOj51tFr35AZXcQ@mail.gmail.com>
	<CABWW-d3tz=Nhk3PtfkaQ1MEcU9XTDFDmLzmV3xgdQqfijcEk+g@mail.gmail.com>
	<4F38EAC5020000250004545C@gw.wicourts.gov>
	<CAG6o=AH=NrCk7SZQ+zaKSehjajnoECn6YGs-YDW7S_SCv3FogQ@mail.gmail.com>
	<4F3B9747.2010804@gmail.com>
	<CADK3HHLy4V5U3qd-HrkFjPe-V5p_MHih2RajHOqDVVA_yW_SGg@mail.gmail.com>
	<CAG6o=AELXcR5XHt3s=1NLx3sRDnhRjtSj2yWFbL7O+KR2Qo2FQ@mail.gmail.com>

15.02.12 14:30, Imran написав(ла):
> @Vitalli - w.r.t Thread priority, I've tried to get the priority off 
> the jvm I'm running, but the thread dump nor jconsole/jvisualvm is 
> giving this out to me. We run 1.6.0_12 on a 64bit linux platform. 
> jvisualvm however shows that the Running percentage of the Finalizer 
> thread is comparatively low. To my knowledge Finalizer thread is low 
> by default, and looking at the Finalizer code, it does appear to be 
> setting the priority to MAX_PRIORITY - 2.
> Anyways that aside, heap dumps I've collected when we had OOMs have 
> pointed at high Finalizer objects and the referent of those have been 
> jdbc3Satement objects, which is why I raised this question. I'm not 
> sure if its common practice to always use finalize() for any mop-up 
> tasks, as I've seen other cautions raised around it, although I can 
> see there are valid cases to do so.
jstack shows you thread priorities.
For me:
Regular thread:
"Thread-69" daemon prio=10 tid=0x000000004683e800 nid=0x6834 waiting on 
condition [0x00007f80a7649000]
Finalizer:
"Finalizer" daemon prio=10 tid=0x00007f80c4001000 nid=0x6d35 in 
Object.wait() [0x00007f80c9747000]

So, priorities are equal.
Regarding heap sizes, that's what I am talking about! If someone holds 
Finalizer thread, especially in some blocking state (say synchronized) 
you will get OOM with a lot of objects that are created much, not ones 
that really holds the thread! That's why it's Running is low - someone 
it blocking on something in this thread. Otherwise if it has work, it 
would be in running state, no matter is OS've given it CPU time. Check 
it with jstack. You can do it even now, while you don't have OOMs you 
should still have the problem root - someone who is sitting in the 
finalizer doing it's work slow. You may even still have some leak, yet 
now while you have much less finalizable objects, the leak is much less 
visible. Note that you may not see it at single call if your cause does 
not take 100% of Finalizer thread time.

BTW: You can try to find the object being finalized from heap dump, 
check all objects visible from finalizer thread.

Best regards, Vitalii Tymchyshyn




view thread (16+ messages)  latest in thread

Message-ID: <4F3BAA22.1040103@gmail.com>
Permalink:  ../4F3BAA22.1040103@gmail.com/
Also on:    postgresql.org/message-id/4F3BAA22.1040103@gmail.com

 · 

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 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-jdbc@postgresql.org
  Cc: tivv00@gmail.com, imranbohoran@gmail.com, pg@fastcrypt.com, Kevin.Grittner@wicourts.gov
  Subject: Re: non-trivial finalize() on AbstractJdbc2Statement
  In-Reply-To: <4F3BAA22.1040103@gmail.com>
  References: <CAG6o=AHE4yfi5E6Ec2FBE=0o3f=QPbN54Fr_HZAysc+m7nJ-Pw@mail.gmail.com> <CADK3HH+rKyg+ss71B0J9AaaKjQduHUj6MYrVaB_qmDaWmPsNew@mail.gmail.com> <CAG6o=AFRjZAEVi_+LSgYSszE669gEjcNBYn6qcHNgZeGMWmHxA@mail.gmail.com> <4F390FF2.2040500@gmail.com> <CAG6o=AGivBfOaytb+0PA2Wp-PMpiYZWyxUNxOj51tFr35AZXcQ@mail.gmail.com> <CABWW-d3tz=Nhk3PtfkaQ1MEcU9XTDFDmLzmV3xgdQqfijcEk+g@mail.gmail.com> <4F38EAC5020000250004545C@gw.wicourts.gov> <CAG6o=AH=NrCk7SZQ+zaKSehjajnoECn6YGs-YDW7S_SCv3FogQ@mail.gmail.com> <4F3B9747.2010804@gmail.com> <CADK3HHLy4V5U3qd-HrkFjPe-V5p_MHih2RajHOqDVVA_yW_SGg@mail.gmail.com> <CAG6o=AELXcR5XHt3s=1NLx3sRDnhRjtSj2yWFbL7O+KR2Qo2FQ@mail.gmail.com> <4F3BAA22.1040103@gmail.com>

* 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