ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Loughran <ste...@apache.org>
Subject Re: report of ant holding on to thread refs in DemuxOutputStream
Date Mon, 25 Apr 2005 11:09:29 GMT
Phil Weighill Smith wrote:
> Perhaps you could use a ThreadLocal instead of the HashMap (if your mode
> of use is always to access/manage the output stream for the current
> thread)? The stored stream would be garbage collected when the thread
> "goes away".
> 

mmm. ThreadLocals can be trouble in their own little way, too, but I see 
your point.

Having just looked at Thread; it doesnt (currently) override 
Object.equals(); equality is pointer based (as is #code). I wonder if 
there is a way to use that.

Alternatively, an extension of WeakReference that caches hashCode and 
forwards equals() when to its referent (when not null) could be used in 
a WeakReferenceHashTable of our creation...


> Phil :n.
> 
> On Mon, 2005-04-25 at 10:54 +0100, Steve Loughran wrote:
> 
>>Forwarding bugrep from a friend. The implication is that  non-forked 
>>Java code can cause trouble
>>as the Demux logic hangs on to thread refs. I guess we could move to 
>>weakrefs and purge sporadically (how sporadically ?).
>>
>> > We finally got to the bottom of the problem by switching to IBM's JVM
>> > and Heap Analyzer tool.
>> >
>> > It turns out that when a java task is running within Ant's JVM (i.e. not
>> > forked), System.out is redirected to an Ant class called
>> > org.apache.tools.ant.DemuxOutputStream. This keeps a HashMap which uses
>> > the Thread.currentThread()  as the key. Thus, a strong reference is kept
>> > to each Thread object that has ever written to System.out  (e.g. the
>> > java logging console handler). There are certain bursty client
>> > access patterns that cause Jetty of be continually varying the size of
>> > the its thread pool, by killing old threads and the later creating new
>> > threads. Put these things together and you have a problem! The Weak
>> > References also come into it, somewhere....
>> >
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
>>For additional commands, e-mail: dev-help@ant.apache.org
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
> 


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


Mime
View raw message