Memory organization
Name Server memory
Name Server requires a user to provide a memory class for the allocation of Name Server stack, entries and an array of flags indicating if an entry is used. The hash table is a Name Server’s local variable, so it is allocated on the Name Server task stack. The memory is organized according to the following image:
The current implementation uses 59 indexes in the hash table. Each index is a pointer, i.e. 4 bytes. The hash table will take:
from the Name Server task stack. There are two runtime allocations from the memory class. One block is for entries memory. Entry size is 20 bytes and can store up to 8 bytes of user data. The second block is used for an array of flags indicating if an entry is used. Each flag takes 1 byte.59 * 4 B = 224 B
Name Server hash table
The following image shows the hash table memory organization and the possible state of the hash table after registering three entries. Two of them have the same hash key (index 2
in the hash table), resulting in chaining these two entries into a linked list under the hash key.
The image below shows the same state of the hash table but simplified and with more abstraction.