swarm-support
[Top][All Lists]
Advanced

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

Re: am I wasting memory?


From: Benedikt Stefansson
Subject: Re: am I wasting memory?
Date: Fri, 19 Jun 1998 22:32:30 +0200

Paul E. Johnson wrote:

> Please pardon me for asking such an obvious question, but since I've
> got no colleagues to talk to about ojb-c, sometimes I just need to ask.
>
> I have agents that have objects inside them.

Strictly speaking, your agents have instance variables that are pointers to
objects, right?

> In modelswarm, I have (what I now understand to be) the usual approach
> where the agents are created in a loop and their parameters are created
> and then passed into them with set methods.
>

[snip]

> The loop creates an agent "Recruiter" and an object "aPosition"
> which is then passed into
> Recruiter.  Inside the Recruiter.m file, there is a create statement
> for the object where "aPosition" gets passed into, and the code works
> as far as I can see.
>
> The question is am I wasting memory inside this loop recreating this
> object aPosition over and over again?  Each time it steps, it is
> allocating temporary space for aPosition, right.  Are those spaces
> being added up and wasted?  Is this the kind of place where I need
> to use the drop command?
>

You are right that you would be wasting memory with this method, if you are
copying the information from the Position instance into another Position
instance. Why don't
you simply pass the pointer as you do, and then use that instance you have
already created
and initialized in the Recruiter?

> Or would I be better off putting aPosition as an object inside ModelSwarm,
> and then each time through the loop I could just set new values inside
> it and pass it to the Recruiter. That way, I'd only have one object
> sitting around.

A matter of taste and of course the purpose of the Position objects. But this
method
would certainly be much more sensible, if you want to stick to creating a new
Position
instance in each Recruiter...

--
With best regards,
-Benedikt

-------------------------------------------------------------------
Department of Economics, UCLA, Los Angeles, CA 90095-1477, USA
Tel: (310) 825 4126     Fax: (310) 825 9528

4/3-7/1 1998:
Dipartimento di Economia, Universita di Trento, 38100 Trento, ITALY
Tel: +39 (461) 88 22 46 Fax: +39 (461) 88 22 22




                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.
                  ==================================


reply via email to

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