[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [Swarm-Support] memory problems
From: |
Marshall, James A R |
Subject: |
RE: [Swarm-Support] memory problems |
Date: |
Wed, 4 Jun 2003 17:06:53 +0100 |
Paul,
just to remind you, I had a look at memory leaks to do with probes over
the last year or so and wrote some test code... could be related to
Marcello's problem:
http://www.santafe.edu/projects/swarm/archive/list-archive.0209/0072.html
Not sure if that was the last word I had to say on the subject, as the
mailing list archives seem to be in a bit of a sorry state ... searching
doesn't work, archives after May 2002 aren't indexed, and I can't find any
of the archives for 2003.
Hope this is of some help,
James
---
Dr James A R Marshall
Complex Systems Modelling Group (COSMIC)
Department of Earth Science and Engineering
Imperial College London
Tel: +44 (0)20 7594 7493
Fax: +44 (0)20 7594 7444
Container World Project - http://www.ese.ic.ac.uk/research/containerworld/
-----Original Message-----
From: Paul E. Johnson [mailto:address@hidden
Sent: 04 June 2003 16:27
To: address@hidden
Subject: Re: [Swarm-Support] memory problems
THanks very much for pointing me at this problem. As I expected, it is a
memory leak related to probe creation, and I'm going to keep trying to
understand why it happens.
pj
Marcello wrote:
>Thanks a lot for the reply. Following Paul's suggestion, I wrote a
>method to make the computations I needed on the agents, so I do not need
>EZDistribution anymore.
>
>In case someone might be interested in debugging the memory leak, I have
>done some experiments with EZDistribution (and EZBin as well), and the
>problem does not seem to be related with dropping the object: I found
>that there is a huge memory usage increase even when only *one*
>EZDistribution is created, and each agent only updates it.
>
>Specifically, I create a single instance of EZDistribution in
>SwarmModel, which can be accessed by each agent via a method call.
>Now each agent calls the collection upon which EZDistribution operates,
>the agent cleans up the collection and add new agents, updates the
>distribution and forget about it. Even in this case, I can get my
>program using up to 300mg in a little while.
>
>CODE
>in Swarm model (- buildObjects )
>
> somePeople=[List create: [self getZone]];
>
> somePeopleTab=[EZBin createBegin: [self getZone]];
> [somePeopleTab setTitle: "stats"];
> [somePeopleTab setGraphics:0];
> [somePeopleTab setBinCount: 5];
> [somePeopleTab setLowerBound: 0];
> [somePeopleTab setUpperBound: 5];
> [somePeopleTab setCollection: somePeople ];
> [somePeopleTab setProbedSelector: M(getTypology) ];
> [somePeopleTab createEnd];
>
>//// other code
>
>- getSomePeople {
>
>return somePeople;
>}
>
>
>- getSomePeopleTab {
>
>return somePeopleTab;
>}
>
>
>(In Agent.m)
>
> id observed;
> id group;
>
> group=[model getSomePeople];
> [group removeAll];
>
> //this fill up "group"
> for (i=0; i<10;i++) {
> while ([group contains: (observed = [self look])] ) ;
> [group addLast:observed];
> }
> [[model getSomePeopleTab] update]; //if I remove this, no memory
>problem occurs. With this line, the program grows (very roughly) about
>1mg for each thousand calls .
>
>
>// other unrelated stuff
>
>
>
>
>
>Thanks again
>marcello
>
>
>
>
>On Tue, 2003-06-03 at 20:35, Paul E Johnson wrote:
>
>
>>I agree that the drop on the EZDistribution object should give all the
>>memory back, but I don't think most people have tried to use that class
>>in this way and so, if there is a memory leak, we have not been alerted
>>to it yet. I found a memory leak, which I still have not solved, in a
>>method that used probes to retrieve double-valued variables, and if you
>>are doing that, I expect you could see the same issue.
>>
>>I think that you should redesign your class so that each agent only
>>creates one EZDistribution as an instance variable and then use it over
>>and over. There is no need to create and drop at every time.
>>
>>The other (better!) possibility is you should find a better way to
>>collect the information you want. For example, are you just trying to
>>get a tabulation of how many agents there are in each group? If so,
>>consider using a method like (off the top of my head, excuse typos)
>>
>>
>>suppose there is an instance variable
>>
>>int tabulator[6]; //need 6 because your example shows values from 0 to 5
>> //not 5 binCount as you have;
>>
>>and somewhere you initialize that to 0's
>>
>>Then call a method that does the tabulation. This will be much faster
>>than creating a big old EZDistribution.
>>
>>- tabulateDistribution
>>{
>> id index = [group begin];
>> id anObject;
>>
>> for (anObject=[index next]; [index getLoc == Member];
>>anObject=[index next])
>> {
>> int agentValue = [anObject getTypology];
>> tabulator[agentValue]++;
>> }
>>}
>>
>>
>>Or, if you just want to calculate an average or standard deviation, you
>>can do that more easily with EZGraph, I can show you how if you need.
>>
>>Sorry, gotta run to a meeting.
>>
>>
--
Paul E. Johnson email: address@hidden
Dept. of Political Science http://lark.cc.ukans.edu/~pauljohn
University of Kansas Office: (785) 864-9086
Lawrence, Kansas 66045 FAX: (785) 864-5700
_______________________________________________
Support mailing list
address@hidden
http://www.swarm.org/mailman/listinfo/support