[SNMP4J] DefaultUDPTransportMapping - java.lang.OutOfMemoryError

Mathew Rowley mathew_rowley at cable.comcast.com
Wed Feb 25 06:38:20 CET 2009


When profiling an application which has a set of threads that use TreeUtils
to SNMP walk.  No matter how many threads I use, I eventually get the
following OOM exception:

java.lang.OutOfMemoryError: Java heap space
Exception in thread "DefaultUDPTransportMapping_192.168.0.10/0"
java.lang.OutOfMemoryError: Java heap space

Is there something I need to explicitly define in the TreeListener to close
the thread when the walk has completed (besides notify())? Or is there
something I need to do to clear the thread out of memory when its finished
executing?
It seems like the Object that is not being destroyed is:
java.util.TreeMap$Entry
This is what I currently have ­ any help would be appreciated.  Thanks.

    public void finished(TreeEvent e) {
        if ((e.getVariableBindings() != null) &&
(e.getVariableBindings().length > 0)) {
            next(e);
        }
        
        if (e.isError()) {
            this.collector.increaseTotalCmtsErrors();
            logger.error(new StringBuffer("There was an error during SNMP
walk (").append(host).append("): ").append(e.getErrorMessage()).toString());
        }
        
        // Let the collector know the thread has finished, and increase the
total counter
        collector.increaseTotalCmtsFinished();
        collector.getFreeThreadsQueue().add(new Integer(threadIndex));
        
        // Show the thread has finished
        synchronized(this) {
            this.notify();
        }
    }

    public boolean next(TreeEvent e) {
        String mac = getVariable(e);
        
        logger.debug(new StringBuffer("Adding to queue: ").append(mac));
        this.collector.addMac(mac);
        
        return true;
    }
-- 
MAT



More information about the SNMP4J mailing list