DalekenMUD 1.12 documentation.
Updated 7 June 2000. Based on original Envy 2.2 documentation. |
Memory Management Overview |
---|
Daleken contains the following memory regions: run file memory; stack; string space; and permanent space. The approximate sizes of these regions are: Runtime memory ??? String space 1279 k Permanent space 1345 k TOTAL 3612 k Note that the value for string space can be modofied by changing
One thing to consider with permanent memnory is that memory that is claimed is recycled by the mud, so for a short time it will spend time grabbing memory, then the amount used will settle. The mud had been running for an hour before taking these measurements so there shouldn't be too much movement. See below for details on permanent memory. |
Run File Memory |
The Daleken executable file has a large amount of code, optimised and stripped this weighs in slightly under 1Mb, with full debugging symbols, this bloats to around 2.7Mb. The following command compiles Daleken with optimised code.
This takes a fair while longer than the standard make.
|
Stack |
We have never measured stack usage, but estimate it's somewhere between
600Kb and 1Mb. Daleken has a wide, shallow calling tree. The largest
consumers of stack memory are local buffers of size
If you port Daleken to a machine with 1024k or less of stack, you should instrument your object code with stack-usage measurements. Most compilers for machines in this range have an option to do this. |
String Space and fread_string() |
At boot time, the function fread_string() is used to read in ~-delimited strings from area files. These strings are stored into string space. After all of the area files are read in, that string space area is read-only for the duration of the program. The excess will be used for new string generation. Duplicate strings are stored only once into string space; hashing is used to achieve this. The hash code for a string is simply its length. Each string in string space is prefaced with a backpointer to the previous string with the same hash code. (Aliasing through a union is needed to read and write these pointers, because they can start at any byte boundary, and thus are misaligned). When If After area-file loading is over, The functions
This strategy not only saves megabytes of memory through string re-use, but also saves processor time as well. Thus a cheap method is needed for deciding whether a given string is in
string space. This is one reason why strings are stored in one contiguous
region of size
Collecting all strings into one region has another advantage: locality of reference. Most strings are unused most of the time. Because they are not interspersed with other dynamically allocated memory, a virtual memory operating system can page out almost all of the string space without affecting performance. After boot time, the unused end of string space is used for new strings the game might generate. This amounts to about 250k in Daleken. On a VM system, unused space is paged out quickly, so it doesn't hurt to leave it alone. If the new strings generated by the game overflow string space, you will be notified and the game will make do. If you add a lot of areas you may need to increase
Envy 2.2 changed its string memory management from Envy 2.0 through Fusion's Shared String Manager v2.2. Previously new strings generated by the game which overflow string space are lost and cannot be shared. Now, overflow strings are shared until not needed and then freed using
There is some gain in performance with the improved string management.
Though we lose it all once we start managing overflow. It is suggested
setting |
Permanent Space - Heap |
This space holds everything else: all of the area file non-string data; all of the created mobiles and objects; descriptor and player character structures; you name it. This space is dynamically allocated from Unlike string space, permanent space grows on demand;
You can adjust the block size by changing Daleken never calls Variable-sized blocks don't fit the per-structure-type free-list model.
The functions |