Search code examples
stringmemoryschemeracket

What is the memory footprint of a character in a byte string when compared to a character in a string (in Racket)?


What is the memory footprint of a character in a byte string when compared to a character in a string in Racket? I was trying to look it up but cannot find it anywhere.

Is there any way I could compute such value?


Solution

  • Racket (CS) internally represents strings as UTF-32, so each character occupies 4 bytes. On a 64-bit platform, a string has an 8 byte header and is 16-byte aligned.

    A byte string is an array of bytes by definition.