[MUD-Dev] [TECH] String Classes, Memory Management, and Fragmentation

Justin Rogers justin at mlstoday.com
Tue Jul 10 09:48:27 New Zealand Standard Time 2001


> Been pondering multiple ways to solve the issue of Heap management
> and the string issue is a thorn in my side.

Well, I can't talk about for the MMPORGS, but I can describe in some
little detail as to how the CLR (.NET) does it.  Every string is
represented as an immutable object so you can't grow/truncate
strings without creating a brand new string.  Each of these strings
is stored linearly in a memory space and is pointed to via a member

If the same string is used multiple places it gets shared amongst
all places it's used.  Any time a new string needs to be created we
add another string in the linear address space.  To overcome the
difficulties of actually building a string of many parts (each
intermediate appendage would normally create a new string) we have a
StringBuilder class which works on a dynamically sized Character
array so you can build strings up and at some point where you want
we convert the array to one of our immutable strings to be passed

If you'd like more information on how we actually declare the string
space and grow and shrink it as strings are added let me know and I
can probably get the information.

Justin Rogers 

MUD-Dev mailing list
MUD-Dev at kanga.nu

More information about the MUD-Dev mailing list