Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4777499
Votes 0
Synopsis (ch) Remove finalize methods from all channel classes
Category java:classes_nio
Reported Against mantis
Release Fixed 1.4.2(mantis)
State 10-Fix Delivered, request for enhancement
Priority: 3-Medium
Related Bugs 4081750 , 4827358
Submit Date 12-NOV-2002
Description
Performance testing has shown that the finalize methods in the channel classes
impose a significant GC penalty upon server-type programs that must deal with
thousands of new open channels per second.  These finalize methods should be
removed.

--  xxxxx@xxxxx  2002/11/12
Work Around
N/A
Evaluation
Yes.  --  xxxxx@xxxxx  2002/11/12
Comments
  
  Include a link with my name & email   

Submitted On 04-APR-2003
s-koehler
does that mean, that a socket is never closed when it isn't
closed within the user-code?


Submitted On 15-APR-2003
cowwoc
I for one think this is retarded... This is likely to lead to leaky 
channel issues. I *know* it is up to the developer to weed 
these out but they are hard to locate and it makes a lot of 
sense for the garbage collector to actually do its job and 
clean up the resource.

In so far as performance is concerned, work on optimizing the 
garbage collector so that *all* classes making use of 
finalizers will run faster, instead of hacking Channel objects.


Submitted On 12-MAY-2003
xxiii
Please at least make sure that the javadoc in all relevent places indicates the need for the channels to be explicitly closed. Many people assume or rely on finalizers cleaning up native resources eventually (even though finalizers aren't guaranteed to run), especially when there is not specific documentation warning that they won't be.


Submitted On 01-JUL-2003
xtarka0
I would hope that the affected classes will register their new 
instances with a PhantomReference subclass and a 
ReferenceQueue. So that when the instance is reclaimed by 
the garbage collector, any associated resources can be closed 
when the PhantomReference is posted to the 
ReferenceQueue. Otherwise, resource leaks may occur.

A PhantomReference with a ReferenceQueue is a better way 
to track instance reclamation than finalize() methods.



PLEASE NOTE: JDK6 is formerly known as Project Mustang