[Pogamut-list] Full memory

Daniel pogamut-forum at artemis.ms.mff.cuni.cz
Thu Apr 16 12:23:42 CEST 2009


Re: Re: Full memory

Author: Daniel


> Are you using anonymous classes as listeners? Do you use them to hook agents to something outside the agent?

Im not using anonymos classes, but that was a really good thinking anyway, thx Jakub!

Here is how I work:
protected void postPrepareAgent() throws PogamutException {
  body.addTypedRcvMsgListener(rayCasting, MessageType.AUTO_TRACE_RAY);
}

RcvMsgListener rayCasting = new RcvMsgListener() {
 (...)
};

However, I`ve done what you said and now I use the shutdownAgent() method, just in case :D, where I try to delete as much as I can.

    @Override
    // Clean up after the end of simulation of agent
    protected void shutdownAgent() throws PogamutException {
        log.log(Level.SEVERE, "bye bye");
    
        body.removeRcvMsgListener(hearNoise);
        body.removeRcvMsgListener(misilComming);
        body.removeRcvMsgListener(botDamage);
        body.removeRcvMsgListener(pathGB);
        body.removeRcvMsgListener(stopShooting);
        body.removeRcvMsgListener(rayCasting);
        body.removeRcvMsgListener(adrenalineGained);

        body.removeAllRaysFromAutoTrace();

        body.closeClient();

        System.gc();
    }





More information about the Pogamut-list mailing list