[DGD] Some questions

Felix A. Croes felix at dworkin.nl
Tue Apr 1 01:46:13 CEST 2003


"Ben Chambers" <bjchamb at bellsouth.net> wrote:

> If I wanted every object to have a pointer to the object daemon, I know I
> would do something like:
> object objectd;
> objectd=...;
>
> It should go in the auto object of course.  But wouldn't that be a memory
> problem to have that many copies of pointers to the object daemon?  Is it
> possible to just use like a static in C++ so that only one instance of the
> pointer exists but they can all access it?

The size of an object variable is, by default, 8 bytes.  Whether this is
too much overhead is for you to decide.  The only alternative to storing
information in all objects is storing it in a central object accessed by
all.


> Also, in Design Patterns there a concept known as a flyweight.  This concept
> works basically like this.  If you have a string such as char* msg=new
> char[10]; strcpy(msg, "hello\n");, then instead of actually having multiple
> copies of that string, you can copy the pointer, which is faster and saves
> memory.  Is this possible to do using object pointers or something in DGD?
> For example, for every instance of a weapon, instead of actually copying the
> string, simply point to a copy of the text?  Would this make any difference
> on performance (memory or speed wise?)

DGD makes an effort to have only one copy of each unique string per
object, but strings are not generally shared between objects.  Whether
or not this is sufficient, or whether you want to use a central object
for this as well, is once again up to you.

Regards,
Dworkin
_________________________________________________________________
List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list