Issue Details (XML | Word | Printable)

Key: NET-100
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Mark Johnson
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Commons Net

TelnetInputStream zombie thread memory leak, FTPClient TelnetClient

Created: 17/Sep/04 03:05 PM   Updated: 16/May/06 12:20 PM
Return to search
Component/s: None
Affects Version/s: Nightly Builds
Fix Version/s: None

Time Tracking:
Not Specified

Environment:
Operating System: HP-UX
Platform: HP

Bugzilla Id: 31272


 Description  « Hide
If myFTPClient.setReaderThread(false) and many ftp clients are instanciated
over time, the VM gets out of memory errors. The problem is that the underlying
TelnetClient's TelnetInputStream creates a new thread that it never uses (never
starts, or joins). The VM is unable to garbage collect these zombie threads.
This problem is paticularly notable given that several users have observed
hangs doing continual ftp unless setReaderThread(false). This observed on hpux
jdk 1.3 <todo lookup specific version>

Here's a patch:

cvs server: Diffing src/java/org/apache/commons/net/telnet
Index: src/java/org/apache/commons/net/telnet/TelnetClient.java
===================================================================
RCS file: /home/cvspublic/jakarta-
commons/net/src/java/org/apache/commons/net/telnet/TelnetClient.java,v
retrieving revision 1.12
diff -r1.12 TelnetClient.java
100,101c100
<
< tmp = new TelnetInputStream(input, this);

> tmp = new TelnetInputStream(input, this, readerThread);
Index: src/java/org/apache/commons/net/telnet/TelnetInputStream.java
===================================================================
RCS file: /home/cvspublic/jakarta-
commons/net/src/java/org/apache/commons/net/telnet/TelnetInputStream.java,v
retrieving revision 1.11
diff -r1.11 TelnetInputStream.java
56c56
< TelnetInputStream(InputStream input, TelnetClient client)

> TelnetInputStream(InputStream input, TelnetClient client, boolean
readerThread)
72c72,74
< __thread = new Thread(this);

> if (readerThread) { > __thread = new Thread(this); > }
76a79
> if (__thread==null) { return; }
498c501
< if (__thread.isAlive())

> if (__thread!=null && __thread.isAlive())



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Mark Johnson added a comment - 17/Sep/04 03:47 PM
observed on: java version "JavaVM-1.3.0.00"
Java(TM) 2 Runtime Environment, Standard Edition (build jinteg:11/28/00-11:08)
HotSpot VM (build 1.0.1fcs jinteg:11/28/00-13:54 PA2.0, mixed mode)

Daniel Savarese added a comment - 24/Sep/04 12:07 PM
Bruno was responsible for adding setReaderThread, so I was kind of hoping
he'd chime in and look at this. However, it's pretty clear from looking
at the code that he overlooked what happens with TelnetInputStream, so I'm
applying your fix. Please verify it has the desired effect before closing.
I can't wait until we get rid of TelnetInputStream and TelnetOutputStream
once and for all.