commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sandy McArthur" <sandy...@gmail.com>
Subject Re: svn commit: r383220 - /jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/LineIterator.java
Date Sun, 05 Mar 2006 03:03:29 GMT
I don't see how this benefits anything and it has a negative effect on
the whole JVM.

I would think it's common to use a LineIterator entirely in one method
which means an instance could live entirely in the eden space. The
presence of a finalizer method causes the JVM to register the object
in a queue that eventually executes the finalize method. Since this is
another thread this forces the JVM to promote the object from eden
space to old space in the heap and it requires more work to garbage
collect old space compared to the eden space.

I can dig up more but I found this with a quick google:
http://www-128.ibm.com/developerworks/java/library/j-jtctips/j-jtc0319a.html
http://www.javaperformancetuning.com/news/interview041.shtml (see last Q&A)

Also, I don't see any "resource leak" in my read of the LineIterator
code. I see a resource clean up delay, if there is such a concept, but
no leak.
http://svn.apache.org/viewcvs.cgi/jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/LineIterator.java?view=markup

On 3/4/06, scolebourne@apache.org <scolebourne@apache.org> wrote:
> Author: scolebourne
> Date: Sat Mar  4 15:18:46 2006
> New Revision: 383220
>
> URL: http://svn.apache.org/viewcvs?rev=383220&view=rev
> Log:
> Add finalize method
>
> Modified:
>     jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/LineIterator.java
>
> Modified: jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/LineIterator.java
> URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/LineIterator.java?rev=383220&r1=383219&r2=383220&view=diff
> ==============================================================================
> --- jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/LineIterator.java
(original)
> +++ jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/LineIterator.java
Sat Mar  4 15:18:46 2006
> @@ -150,6 +150,14 @@
>          throw new UnsupportedOperationException("Remove unsupported on LineIterator");
>      }
>
> +    /**
> +     * Finalize which closes the underlying reader.
> +     * Do not rely on this method to handle cleanup - call closeQuietly yourself.
> +     */
> +    protected void finalize() throws Throwable {
> +        close();
> +    }
> +
>      //-----------------------------------------------------------------------
>      /**
>       * Closes the iterator, handling null and ignoring exceptions.
>


--
Sandy McArthur

"He who dares not offend cannot be honest."
- Thomas Paine

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message