[Pogamut-list] Full memory
nvh
pogamut-forum at artemis.ms.mff.cuni.cz
Thu Apr 23 01:05:25 CEST 2009
Re: Re: Full memory
Author: nvh
> Are you using anonymous classes as listeners? Do you use them to hook agents to something outside the agent?
>
> If so - it may be your problem... every anonymous class instance contains a strong reference to the instance
> that encloses it. If you register such listener somewhere else in the code (then it mean there are the strong
> reference from outside of the agent to your listener that has the strong reference to the agent) it
> will make instance of the agent strongly reachable even after you drop the reference to the agent (mind the listener ;-))
>
> In such cases you have to drop listeners inside shutdownAgent() method (or something like that :))
Can you explain this problem more thouroughly? I think I have this problem, but I don't know for sure and I don't know how to fix it.
I create anonymous Listeners to my agents in an Experiment class, and from the listener I reference the ExperimentDescriptor. I also created a reference to the Agent class from the AgentBody, can that be a problem?
I don't really understand a lot about these references and the garbage collection, so I would be very glad if you could help me out here.
Thanks!
Niels
More information about the Pogamut-list
mailing list