Yes and no, I think. They're not shortstrings any more, but rather pointers. They use a copy-on-write dealie with reference counting. This means that for each string, you get a pointer to the data, a reference count and a length (this is hidden from you). This means that you get memory allocation when using them (sometimes).

The problem would seem to be that it uses some memory allocation behind the scenes - maybe. I seem to recall reading that this is the case, and that it introduces a little overhead (maybe in Ray Lischner's Delphi in a Nutshell book?). Something's fishy there, anyway. It's quite interesting that assigning it a value in the global area gives a massive increase in the exe size! I'd imagine that dynamic arrays would also cause bloat. I'll check now...

YEP! Declaring a dynamic array (var x: array of integer) increases the size up to 8.5K (half a K). If I then use SetLength, the size jumps up to 16K! It looks like the memory management is playing silly buggers. If I use a pointer to integer + getmem then there **was the same size increase as with strings** to 13.5K.

I tried declaring a pointer to an integer and using LocalAlloc instead (a win32 function). Guess what? No size increase - 8K still . I'm not sure what alloc function is best (apparently LocalAlloc and GlobalAlloc are the same, and HeapAlloc seems slightly more involved, in that you have to create it first(?)).

Another interesting result! I've found that declaring a global var as a string array, like this...

[pascal]var x: array[0..0] of string = ('blah');[/pascal]

...increased the size to 14K (that's one K more than a normal string, even though it amounts to the same thing). Hmm! (Again, an array of 1 integer, initialised, didn't increase the exe size).

It looks like you should watch out for strings, since they're dynamically managed behind the scenes! The same goes for GetMem or New and dynamic arrays.

It's probably an idea to wrap up memory allocation around the Win32 API calls, then.

Anyone else tried stuff like this? What interesting results are still to come...