Hello Konstantin,
On Wed, Oct 27, 2010 at 11:53 PM, Konstantin Kolinko
<[email protected]> wrote:
> 2010/10/28 Leon Rosenberg <[email protected]>:
>>
>> Well, that would just move the problem from stopping Timer to calling
>> shutdown on Executor, wouldn't it?
>>
>
> The problem is with the Thread.getContextClassLoader() for your
> thread. It contains a reference to the webapp classloader, and thus
> does not allow to GC it.
But I can't detect any obvious Thread.getContextClassLoader() calls in
the code below:
public class BuiltInMemoryPoolProducer implements IStatsProducer{
/**
* The id of the producers. Usually its the name of the pool.
*/
private String producerId;
/**
* Associated stats.
*/
private MemoryPoolStats stats;
/**
* Stats container
*/
private List<IStats> statsList;
/**
* The monitored pool.
*/
private MemoryPoolMXBean pool;
/**
* Timer instance for this producer type.
*/
private static final Timer timer = new Timer("MoskitoMemoryPoolReader",
true);
/**
* Creates a new producers object for a given pool.
* @param aPool
*/
public BuiltInMemoryPoolProducer(MemoryPoolMXBean aPool){
pool = aPool;
producerId =
"MemoryPool-"+pool.getName()+"-"+(pool.getType()==MemoryType.HEAP?
"Heap" : "NonHeap");
statsList = new CopyOnWriteArrayList<IStats>();
stats = new MemoryPoolStats(producerId);
statsList.add(stats);
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
readMemory();
}
}, 0, 1000L*60);
readMemory();
}
@Override
public String getCategory() {
return "memory";
}
@Override
public String getProducerId() {
return producerId;
}
@Override
public List<IStats> getStats() {
return statsList;
}
@Override
public String getSubsystem() {
return SUBSYSTEM_BUILTIN;
}
private void readMemory() {
MemoryUsage usage = pool.getUsage();
stats.setCommited(usage.getCommitted());
stats.setUsed(usage.getUsed());
stats.setInit(usage.getInit());
stats.setMax(usage.getMax());
}
/**
* This method is used internally for virtual producers / stats.
* @return
*/
MemoryPoolStats getMemoryPoolStats(){
return stats;
}
}
>
>
> Note, that the webapp classloader cannot be used anymore once the
> application is stopped. Any attempt to load classes through it will
> fail.
>
> Best regards,
> Konstantin Kolinko
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]