I've done an example here to see how much memory consumes each variable and I noticed that a variable of type ShortString
consumes 256 while a variable of type String
consumes only 4. Here's an example for verification:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
String1: ShortString;
String2: String;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
String1 := 'Teste';
String2 := 'Teste';
ShowMessage(Format('String1: %d'+#13+'String2: %d',[SizeOf(String1),SizeOf(String2)]));
end;
end.