Return-Path: Delivered-To: apmail-cassandra-dev-archive@www.apache.org Received: (qmail 6354 invoked from network); 5 Jun 2010 13:11:00 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 5 Jun 2010 13:11:00 -0000 Received: (qmail 69069 invoked by uid 500); 5 Jun 2010 13:11:00 -0000 Delivered-To: apmail-cassandra-dev-archive@cassandra.apache.org Received: (qmail 68994 invoked by uid 500); 5 Jun 2010 13:10:59 -0000 Mailing-List: contact dev-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list dev@cassandra.apache.org Received: (qmail 68975 invoked by uid 99); 5 Jun 2010 13:10:59 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 05 Jun 2010 13:10:58 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of jbellis@gmail.com designates 74.125.82.44 as permitted sender) Received: from [74.125.82.44] (HELO mail-ww0-f44.google.com) (74.125.82.44) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 05 Jun 2010 13:10:52 +0000 Received: by wwg30 with SMTP id 30so415483wwg.31 for ; Sat, 05 Jun 2010 06:10:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=gOiiJSQWNlYOE5uYEzCN/j9hF7tvccgaGBfn3proOVg=; b=r+NfAZaJWfzdnwTCl+SnTtKwvAYcb2N+hnfgtQMbpWu1HEbH0b9pd9UnKHdkwj+yLf UIu2q0hDWb6qhdSGR88Zqi9ygOiJb8/5otBFAvQNgfpYQX4cXavoKrWOksn20exWM1+W A34UXPOoUtHVSl+QtrF5EbJg8dnAgftJQfSZY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=coNnRyM6q6Ufbq0acHsh5JRXwUv2CV1T18YX92O/7ajuR8Fe79eiVsvla1DrTmB2hM 1Tj5Q8SewzT1PZZz6Znx9m+r+Ft2FPTdoH6rP0FQw+kp/rrduwq9bCl2XS1LqTVbF9xV K9PHU+Uq2PX8V1Ux8ePSirR7yVKX2y3xJeUn8= Received: by 10.216.177.85 with SMTP id c63mr701489wem.14.1275743432167; Sat, 05 Jun 2010 06:10:32 -0700 (PDT) MIME-Version: 1.0 Received: by 10.216.17.197 with HTTP; Sat, 5 Jun 2010 06:10:12 -0700 (PDT) In-Reply-To: References: From: Jonathan Ellis Date: Sat, 5 Jun 2010 06:10:12 -0700 Message-ID: Subject: Re: PhantomReference in Cassandra To: dev@cassandra.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org >From what I have read, allowing the reference to be GC'd itself is equivalent to calling clear. Does adding clear() make an observable difference? On Sat, Jun 5, 2010 at 1:31 AM, Anty wrote: > ---------- Forwarded message ---------- > From: Anty > Date: Sat, Jun 5, 2010 at 4:30 PM > Subject: PhantomReference in Cassandra > To: user@cassandra.apache.org, chukwa-dev > > > Hi:All > in the code of SSTableReader.java > =A0private static final ReferenceQueue finalizerQueue =3D = new > ReferenceQueue() > =A0 =A0{{ > =A0 =A0 =A0 =A0Runnable runnable =3D new Runnable() > =A0 =A0 =A0 =A0{ > =A0 =A0 =A0 =A0 =A0 =A0public void run() > =A0 =A0 =A0 =A0 =A0 =A0{ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0while (true) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0{ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0SSTableDeletingReference r =3D nul= l; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0try > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0{ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0r =3D (SSTableDeletingRefe= rence) > finalizerQueue.remove(); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0finalizers.remove(r); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0catch (InterruptedException e) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0{ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0throw new RuntimeException= (e); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0try > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0{ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0r.cleanup(); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0catch (IOException e) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0{ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0logger.error("Error deleti= ng " + r.path, e); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > =A0 =A0 =A0 =A0 =A0 =A0} > =A0 =A0 =A0 =A0}; > =A0 =A0 =A0 =A0new Thread(runnable, "SSTABLE-DELETER").start(); > =A0 =A0}}; > > > the PhantomReference SSTableDeletingReference's cleanup() method doesn't > invoked clear() method inherited from Reference, whichi clear the phantom > reference to the referent. > but,the GC enqueues the PhantomReference onto ReferenceQueue before the > phantom reference clears. Is it necessary to invoke the clear() method af= ter > r.clearup() or add clear() method in cleanup() method to accelerate the G= C > process. > =A0 =A0try > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0{ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0r.cleanup(); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0r.clear(); > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0catch (IOException e) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0{ > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0logger.error("Error deleti= ng " + r.path, e); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > -- > Best Regards > Anty Rao > > > > -- > Best Regards > Anty Rao > --=20 Jonathan Ellis Project Chair, Apache Cassandra co-founder of Riptano, the source for professional Cassandra support http://riptano.com