Lecture Notes for Advanced Programming II

22 January 2004 - Strings


Most string implementations will contain a pointer to the character data, a value to keep the number of chracters in the string, and a value to keep the size of the data array. On most current architectures, that results in 4 + 4 + 4 = 12 bytes of overhead.

Fancier string implementations will keep more information and have a larger overhead. For example, a string implementation may use sharing to save space and time, but will have to use a reference count. String implementations that use allocators also have to spend some overhead to keep track of the allocator.


This page last modified on 23 January 2004.