Memory management
Understanding how built-in data types work also means knowing how Delphi manages the memory for them. It helps if you know at least something about Delphi and memory in general. Admittedly, this is a deep topic; something that most programmers—even excellent programmers—only understand in general terms. In other words, don't worry, you can safely forget 90% of the stuff I told you in Chapter 4, Memory Management, and you'll still know enough.
When a Delphi program is running, memory is constantly being allocated, reallocated, and freed. This happens when classes are created and destroyed, when the length of a dynamic array is changed, when strings are modified, lists appended, and so on. If you want your code to perform well, you should be aware of this.
Instead of appending to a string, character by character, you would call SetLength
to preallocate the target length (or some approximation of it) and then store characters in a string. Dynamic arrays can be handled in a similar...