Strings & Memory Usage

clawrenc at cup.hp.com clawrenc at cup.hp.com
Mon Apr 14 08:59:57 CEST 1997


In <199704150252.CAA220829 at out1.ibm.net>, on 04/14/97 
   at 08:07 PM, Greg Munt <greg at uni-corn.demon.co.uk> said:

>Is there a common way to save the memory used up by storing strings?

Yup, its called reference counting.  There are several
implementations, and a vast number of optimisations, but the basic
trick is having a central module control storage of all strings. 
Whenever a string is submitted to the module for storage, it compares
it to the other strings it finds, and if it finds a dupe, increments
the reference count on the dupe and returns that, or adds it as a new
string (no other copy found).

Obvious optimisations enclude hashing the string lookups to speed
determining if the string in question already exists in the pool.

Note: OSE has a very slick reference counted string class.

>I'm  sure something was said on this subject in the RGMA 'MUD Memory'
>thread  (by George Reese, IIRC)

Bugger.  Another thread to dig up.  

>I will probably be using some sort of bytecode compilation on my mud
>now.  Would this method of memory saving simply involve checking a
>list of  those strings currently in memory, and either adding a new
>string, or  adding a pointer to an old string? (that would probably
>slow down the  process unless the storage structure was right, tho)

Bytecoding really has nothing much to do with string compression of
reference counting.  If fact, for my implementation bytecoding _costs_
me memory as I keep the flat-ASCII version and the bytecoded version
about (I need easy compile/decompile).

--
J C Lawrence                           Internet: claw at null.net
(Contractor)                           Internet: coder at ibm.net
---------------(*)               Internet: clawrenc at cup.hp.com
...Honorary Member Clan McFUD -- Teamer's Avenging Monolith...




More information about the mud-dev-archive mailing list