swarm-support
[Top][All Lists]
Advanced

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

Re: [Swarm-Support] size of zone?


From: Gary Polhill
Subject: Re: [Swarm-Support] size of zone?
Date: Wed, 28 Jan 2004 17:27:29 +0000

You might find the following method useful, which counts the number of objects 
in a zone. I'm afraid I don't know how to go from that to the amount of memory 
used in the zone.

-(unsigned long long)countZone: (id <Zone>)z {
  id <List> pop = [z getPopulation];
  id <ListIndex> ix = [pop listBegin: scratchZone];
  unsigned long long c = 0;
  id member;

  for(member = [ix next]; [ix getLoc] == Member; member = [ix next]) {
    if([member isKindOfClassNamed: "Zone_c"]) {
      c += [self countZone: member];
    }
    else {
      c++;
    }
  }
  [ix drop];
  return c;
}

I put this method in ObserverSwarm and use it to create a graph of zones over 
time:

  zoneGraph = [EZGraph create: self
                       setTitle: "Size of various zones vs. time"
                       setAxisLabelsX: "Time" Y: "Size"
                       setWindowGeometryRecordName: "zoneGraph"];
  [zoneGraph enableDestroyNotification: self
             notificationMethod: M(quitZoneGraph:)];
  [zoneGraph createSequence: "scratch"
             withFeedFrom: self
             andSelector: M(countScratchZone)];

...where the countScratchZone method just returns (double)[self countZone: 
scratchZone].

I have found this a useful way of checking for memory leaks.

Hope this helps,

Gary




Gary Polhill
Research Scientist
The Macaulay Institute
Craigiebuckler
Aberdeen AB15 8QH
UK
Tel: +(44) (0)1224 498200 Ext 2238
Fax: +(44) (0)1224 311556
e-mail: address@hidden
http://www.macaulay.ac.uk/
http://www.macaulay.ac.uk/fearlus/

>>> address@hidden 27/01/04 21:46:30 >>>

this is objectiveC swarm question:

i vaguely remember  that there was a way to ask
a zone its size, i.e., the size of things allocated in it.
i poked around the docs and didn't find it.

can it be done?  anyone have any hints?

thanks!
 - r

ps this is an effort to find a memory leak.
   has anyone tried to use mtrace with objectiveC/Swarm?
   does it work ok?

-- 
Rick Riolo                           address@hidden 
Center for the Study of Complex Systems (CSCS)
4477 Randall Lab                
University of Michigan         Ann Arbor MI 48109-1120
Phone: 734 763 3323                  Fax: 734 763 9267
http://cscs.umich.edu/~rlr 

_______________________________________________
Support mailing list
address@hidden 
http://www.swarm.org/mailman/listinfo/support




reply via email to

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