Return-Path: X-Original-To: apmail-lucene-java-user-archive@www.apache.org Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C8EC4F401 for ; Sun, 2 Jun 2013 07:01:46 +0000 (UTC) Received: (qmail 21750 invoked by uid 500); 2 Jun 2013 07:01:44 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 21447 invoked by uid 500); 2 Jun 2013 07:01:44 -0000 Mailing-List: contact java-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-user@lucene.apache.org Delivered-To: mailing list java-user@lucene.apache.org Received: (qmail 21415 invoked by uid 99); 2 Jun 2013 07:01:42 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 02 Jun 2013 07:01:42 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of serera@gmail.com designates 209.85.128.54 as permitted sender) Received: from [209.85.128.54] (HELO mail-qe0-f54.google.com) (209.85.128.54) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 02 Jun 2013 07:01:36 +0000 Received: by mail-qe0-f54.google.com with SMTP id ne12so1169160qeb.27 for ; Sun, 02 Jun 2013 00:01:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=OBg55uiXP4If3dTS+YNnNqu9yXv11oB0qPCxTCgZgX4=; b=Bf1Hb1MaOk1oY+3i2F0BqAPhG9HNsBxVC0ZPHD1vQWPmL2UvMmByJki1uDaxkHulSw LU05MK3opB4Jq47ih1RqyJf5Rn1Mr1NXZFxitol7kRj8zDXM0WxvOBy+dHNIeq885Y7Q za0rsvcb6bEgciEoj84JxJYEGSkksdLvw7E244177hcELsEbU493tFFG5fbnLu+hSER8 Vsq4pYZPjPlbryK4n49/UadUwMlv14JI9wgNuaJhcur5j9BEjfBxsEe3HhKCpnRuSQkD cIYKFsfgdtMB7MuryTc+/NFsWNbjQJe37TF2r16i59CyAZ73fKdiQEuI83tkTvlAZH5p 7MRQ== X-Received: by 10.224.148.19 with SMTP id n19mr14320687qav.66.1370156475770; Sun, 02 Jun 2013 00:01:15 -0700 (PDT) MIME-Version: 1.0 Received: by 10.49.36.10 with HTTP; Sun, 2 Jun 2013 00:00:55 -0700 (PDT) In-Reply-To: References: <6A16E0A7-85EE-423F-9BE9-48F33C249B2A@gmail.com> From: Shai Erera Date: Sun, 2 Jun 2013 10:00:55 +0300 Message-ID: Subject: Re: simple question about decRef To: "java-user@lucene.apache.org" Content-Type: multipart/alternative; boundary=089e0149ca8c066a2404de266a4a X-Virus-Checked: Checked by ClamAV on apache.org --089e0149ca8c066a2404de266a4a Content-Type: text/plain; charset=ISO-8859-1 The best practice is: - The component which calls DirectoryReader.open should call close() - Any code which calls incRef() should match that call with decRef(), preferably in a try-finally clause Shai On Sun, Jun 2, 2013 at 6:18 AM, Yonghui Zhao wrote: > Thanks, Michael. > > My understanding is that close also calls decRef. So if I never call > incRef, I also can call decRef one time, the decRef actually close the > reader since the ref counter is decreased to 0. > > So if we call incRef n times, can I call decRef n+1 times to close the > reader without call close, since I don't know when the ref counter is 1? > > > > > > > 2013/6/2 Michael McCandless > > > Only call decRef if you previously called incRef. They must match one > for > > one. > > > > Also, call close when you are done using the IndexReader. > > > > If you fail to decRef or close then files will be held open and you'll > > eventually exhaust the limit of open file descriptors. > > > > Mike McCandless > > > > http://blog.mikemccandless.com > > > > > > On Fri, May 31, 2013 at 8:12 PM, Yonghui Zhao > > wrote: > > > After we use IndexReader do we always need call decRef explicitly? > > > > > > What will happen, if I don't call decRef? Thanks > > > > > > Sent from my iPad > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org > > > For additional commands, e-mail: java-user-help@lucene.apache.org > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org > > For additional commands, e-mail: java-user-help@lucene.apache.org > > > > > --089e0149ca8c066a2404de266a4a--