[Home] [Groups] - Message: [Prev in Group] [Next in Group]

nu.kanga.list.mud-dev

99: Garbage Collector

[Full Header] [Plain Text]
From: "Artur 'Revinor' Biesiadowski" <abies@pg.gda.pl>
Newsgroups: nu.kanga.list.mud-dev
Date: Thu, 20 Mar 1997 21:09:49 +0100 (MET)
Organization: Kanga.Nu
Patch is at
http://www.pg.gda.pl/~abies/mudpp/patches/art026a.dif
(Fusion - I sent it by mail)

NOTE: it is not complete work ! It is only glimpse at my work to keep you
up to date, allow to flame me for bad constructs and share ideas.

It adds automatic garbage collector to mud++.

How this work:
Some of the classes now inherit from VMObject (VirtualMachineObject)
(this include MudObject, Affect, Exit, Repop and some more)
Every instance has it own private reference counter. When we put pointer
to it in some table (for example LList) we have to increase counter by one
( obj->getHandle() ). If we dereference it somewhen later just reduce counter
by obj->freeHandle(). This apply only to direct pointer handling, as I have
already put most needed calls to top-level funs like rmObjInv() (as opposed
to inv.remove(obj) )
No more delete - just remember to dereference objects correctly and GC
will take care of this later.
GC keeps list of all VMObjects and when it is fired up it scans list for
objects with 0 count. When such objects is spotted it is deleted.

NOTE: this desing of GC is not good for multithreaded environement.
I'm not sure how to solve this - maybe we will need separate GC for each tread?
Neverless, it is future.

Why we need GC ?
It is NOT made to make life easier, but to make some otherwise impossible
things doable. True functionality of GC will show up in VM environement - we
will be able to operate on VM variables without fear that object will be deleted
during some wait/sleep statement.

For now GC is infant, it has many bugs with referencing/dereferencing
(at least one in shellpcs), and it will crash when you will allocate too many
objects (I'm fixing it at the moment).
If you want to play with it there are two commands (besides gdb:)
gcdump - dumps GC stack to logfile (in format type_of_object : count )
gcrun - delete items with 0 reference count
(Hint: your items and goblin + his items are at end of dump)
I'm working hard to correct this and later I will start to port/rewrite
my old Virtual Machine and MudAsm.
I also have to put String, LList, Array and Hashtable to GC - but they will
be handled in other way (or not - I'm not sure)

OK, that was long, enough :)
If you have any questions ask. (I will have to write some doc about this :(
Or maybe you are just totally against GC ? It would save me some work :)

Artur

to keep his Character alive when he goes LD. :> :>I have attempted to balance this by programming some :> :>NPCs to be "marshalls" for other NPCs or controllers of city/town :> :>subsystems. Thus not all NPC scripts are active and consuming :resources :> :>all the time. For instance city guard captains are programmed to :issue :> :>patrol orders and attack orders to their charges. An interesting side :> :>affect is that by taking out a "marshall" or subsystem controller, a :> ^e? :> :>great amount of chaos ensues until a replacement NPC is found. :> :> :Cute. I like this. :> :> Hmmm. I tend to like everything remotely active to be completely active, :> thinking for itself to a greater or lesser extent. : :I agree with this, the type of activity I refer to occurs whether or not :players are :present. The individual tactical activity occurs when players are present. Hmmm. I use macroscopic event prediction to account for whatever happens while an Area is Playerless. Then again, I've got a background in chaos mathematics, thermodynamics, nanotech... I tend to think that way anyway. :> *grin* I modeled a bit of that into my graphical project... I like it :too, :> and hope someone will eventually run such a world with a Physmud++ :base... :> I certainly provided enough support for that, and for alternative :physical :> models... nonetheless, any consistant model will create a better mud, :> whatever the model may be. :> :I would be pleasantly surprised. I suspected that my model to be :inconsistent with :a model based on real physics. My world is round with a hole in the :middle. Water :flows into one hole and out of the other. It is suspended in aether. The :sun is exactly :30 miles in diameter and is in fact a flat golden disc that descends and :ascends into the :hole. The stars are in fact fixed in the firmament of the heavens. The :amount of aether :present in an object determines its attraction or repulsion to earth. Actually quite easy to model. Aether I have done before (For a lark, I modeled Terry Pratchett's Discworld in one simulation... where light is only barely faster (sometimes slower) than sound, and the world rests on the backs of four elephants riding on the shell of a giant space turtle.) Your universe is quite well defined... The forces, as I see them, are Mass/World attraction, Aether/World repulsion.... I could use these, and a proper balance of mass and Aether for your sun, to model the celestial motion of the sun. The fixed stars are not a problem at all (I never bothered to unfix the stars for Singularity 2.... as I never even coded them in.) Water behavior sounds natural... if we have any sort of spin to the world, I could give Aether a polarization value, and water would simply be responding to the pseudo magnetic properties of the Aether field. :> :>They demand sacrifices, quests and generally participate in mortal :> :>affairs. As such they are roleplayed by whomever is granted with the :> :>responsibility. With this in mind, I have done away with my :solar/lunar :> :>timer events and have assigned maintenance and execution of these :events :> :>to the Apollo NPC's and Artemis NPC's subsystems. :> :> Quite nice. How do you model the Deiatic charis :> :What does this mean? I am intimately familiar with Homer,Hessiod, the five :playwrights :and Plato, although only in English translation. Attraction of the gods... the ability of a god to force attraction from any mortal. Kind of a touchy issue. :> Linking scheduling is quite simple in my system, partly because I had to :> allow for the distorted physics of the region around a black hole, the :> effects of time dialation, and simpler matters such as different :planetary :> systems, differing gravitational fields, free fall localities, fluid :> environments... I think I could link in a "gods" system fairly easilly. :> The whole point of Physmud++ is that it can model any, _any_ set of laws :> to the universe. : :Even if these laws are consistent in their inconsistency? I think part of :the :charm of such an environment is that it can conveniently match with :observed :behavior and be believable in context. I keep thinking of the scene in :Monty :Python's Holy Grail where a discussion about how to determine whether the :lady in question was a witch. Can such ridiculous observable behavior :occur :in your physical model. Is the lady, lighter or heavier than a duck? In :my model :there would be ample observable evidence to support the lighter than a duck :theory, since if the lady be a witch she would have a good deal of aether :within. :Thus she would readily be repelled by the earth, more so than a duck. ;-) Sounds like what I would expect from your Aether/Mass model. Yes, the Aether laden witch would be lighter, potentially, than a duck. I want to see an overly enchanted sword lift its owner into the heavens. __ _ __ _ _ , , , , /_ / / ) /_ /_) / ) /| /| / /\ First Light of a Nova Dawn / / / \ /_ /_) / \ /-|/ |/ /_/ Final Night of a World Gone Nathan F. Yospe - University of Hawaii Dept of Physics - yospe@hawaii.edu