Re: Circle Architechture - was Re: [CIRCLE] DG-Script's crashing..

From: Patrick Dughi (dughi@imaxx.net)
Date: 06/02/00


>
> Short of writing your own garbage collection, I recently saw a Boehm
> garbage collection library on Freshmeat.  You might want to check it out
> at http://www.hpl.hp.com/personal/Hans_Boehm/gc/.  I've only used it thus
> far to check for memory leaks in existing projects, which is a nifty
> side-effect.
>
> I would prefer garbage collection over reference counting, although you
> seem to be championing the latter (which is what your system of storing on
> deallocation amounts to).
>

        I currently use the boehm gc library - however it does have some
major shortcomings; it misses much deallocation memory which was arrived
at by way of pointer math - something stock circle uses it's fair share
of.  It also does not stop problems relating to referencing freed
structures.  Circularly linked lists pose problems too (such as character
structures which link to a descriptor, and back again).  In some cases,
too, it causes crashes in the memory allocation procedure, though they are
few and far between (potentially due to a previously smashed stack or the
like).  Oh, and the gc library is not thread-safe - a necessity if you're
using database access.

        I'm not worried about memory usage though - I'm worried about data
encapsulation.  Right now it is trivial to perform an extraction in a
function which is nested in an iterative loop (like perform_violence), and
have that extraction perform correctly only to have the loop fail upon the
next iteration (due to attempted acces of the extracted node).  There are
easy ways around this, and while people are inclined to take the short
route and use direct access to their data structures, using the 'longer'
way of writing access, set, remove, add, search, traverse, etc functions
for at least something as common as our frequently occuring linked list
will save much grief down the road.  At the very least, it modularizes the
system, allowing you to make changes at a single point.  Simple things
like insuring that free'd pointers are set to 'NULL', for example, would
be easy to enforce.

                                                PjD


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 04/10/01 PDT