swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Swarm-Support] Objects on multiple lists


From: Darold Higa
Subject: Re: [Swarm-Support] Objects on multiple lists
Date: Mon, 17 Feb 2003 19:54:40 -0800

On Monday 17 February 2003 04:29 pm, you wrote:

Wow, thanks for the prompt response.  That helps a bunch.

[much of my confusion deleted]

> If you create a separate zone for each agent, and create the agent in
> that zone, then each agent will have a zone. But it does not solve the
> memory leak problem. When you drop the agent, you have to override the
> drop method and then make sure you drop the list when the agent is dropped.

OK.  So far, so good.  I think I get it.

> I don't see what the problem is. If each agent has a list of others, and
> you remove all of those references, then everything gets removed. That's
> what happens on my computer, anyway.

> If that's not what you see, give us a set of code we can test.

Hmm.  I think the previous response explained to me where I was going wrong 
with removing agents.  I thought I was removing agents from a copy of the 
list, but what in fact I was doing was removing agents from the original 
list.  I will make the corrections and this should fix the problem.  If it 
persists I will post some code.

The only confusion I guess I still have is why when I tried to have an object 
create a list in the objects own zone it did not compile.  I guess this is 
where my understanding of zones falls apart.

I thought an object (in this case my TerrainObject) could create a list just 
by doing:

from within an object:
aList = [List create: self];

But this would not let me compile.  Instead I had to do this:

aList = [List create: [modelSwarm getZone]];

I just wanted to know why.

> > 2A.  If a list is made of objects through addLast, what effect will
> > removing and or dropping items from this list have on any other lists?
>
> I don't think it has been answered or discussed much.  I think the
> answer is that the "other lists" will go to hell if you drop an object
> and you don't tell those other lists about it.
>
> It would be a perfect world if  those other lists had "nil" inserted
> where the dropped object used to be, but I was just reminded that  it is
> not so.  I had some hairy memory problems in a program that users sent
> me and the problem was that they were dropping an object from one list,
> but not setting it to nil or removing from the other lists, and so when
> processing those other lists, there was a seg fault because any old
> thing was found at the memory location where the dropped object was.
>
> Lesson: keep careful track when dropping things, make sure they notify
> all lists in which they belong that they are gone.
>
> pj

Yes.  I think I got this part now.  I use a reaperQueue to drop agents from 
my master agent list, and I have a kill method that removes the agents from 
all respective lists before dropping.  It sounds like you can even drop lists 
as long as all agents have been removed from the list first.

Thanks!

Darold


reply via email to

[Prev in Thread] Current Thread [Next in Thread]