[Home] [Groups] - Message: [Prev in Group] [Next in Group]
848: Re: Strings & Memory Usage
[Full Header] [Plain Text]
From: clawrenc@cup.hp.com
Newsgroups: nu.kanga.list.mud-dev
Date: Mon, 14 Apr 97 08:59:57 -0700
References: [1]
Organization: Kanga.Nu
In <199704150252.CAA220829@out1.ibm.net>, on 04/14/97
at 08:07 PM, Greg Munt <greg@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@null.net
(Contractor) Internet: coder@ibm.net
---------------(*) Internet: clawrenc@cup.hp.com
...Honorary Member Clan McFUD -- Teamer's Avenging Monolith...