tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier>
Subject Re: CLOSE_WAIT and what to do about it
Date Sun, 12 Apr 2009 16:26:15 GMT
Caldarale, Charles R wrote:
>> From: André Warnier []
>> Subject: Re: CLOSE_WAIT and what to do about it
>> If these sockets disappear during a GC, then it must mean that they are
>> still being referenced by some "abandoned" objects sitting on the Heap,
>> which have not yet been reclaimed by the GC.
>> Which probably means that the objects in question have gone out of
>> scope, before the socket they used was properly close()'d.
> Your analysis looks reasonable to me.  There are some analysis tools that will examine
a live heap (or dump thereof) and find the reachable and unreachable objects; jhat is a free
one that comes with JDK 6:
Allright, I have done that too.
I generated a Heap dump using
jmap -heap:format=b <pid>

That gave me file heap.bin of some 4.5 MB.
I then used the jhat program to open it.

jhat launches itself by default as a webserver on port 7000, which you 
can access using a normal browser.

That's where my problem starts however, because being a mere Java 
fiddler I don't really know what I am looking at, and what to look for. 
  I did a lot of guesswork anyway, and using my knowledge of the 
application more than the links, I came upon the name of a class that 
looks like it is reponsible for opening/closing the sockets that remain 
I found the following function in the class :
     public void close()
         throws SomeException
         socket = null;
flush() being another function which reads the socket until there's 
nothing left to read, and throws away the result.
"socket" is a property of the object created by this class, obtained 
somewhere else from a object.
Looking at that code above, it is obvious that "socket" is open, until 
it is set to null, without previously doing a socket.close().
I don't know Java enough to know if this alone could cause that socket 
to be lingering until the GC, but I kind of suspect so.
How does a Java expert look at that ?

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message