1

I searched and found out that Packed Record in Delphi uses less space. But why to use Record? Are there any things that a Record can do and Packed Record cannot?

TCourse = Packed Record
CId: String;                   
CName: String;
CDuration: string;
end;
Rajana Deepak
  • 1,302
  • 2
  • 13
  • 28
  • 2
    one reason -> alignment. Performance will go down if data is not aligned... – whosrdaddy Jan 27 '18 at 07:11
  • Generally you want to do the exact opposite. Never pack structures because that destroys alignment. – David Heffernan Jan 27 '18 at 12:20
  • I think the reason for `packed` is mainly historical - it used to be commonplace to store data on disk as a 'file of record' for file-system databases, and with old, tiny hard disks, `packed` could signicantly save diskspace and improve reading speed. – MartynA Jan 27 '18 at 13:27
  • 1
    Another use for packed is if you want to overlay a binary structure with an ordered structure. – Toon Krijthe Jan 29 '18 at 09:42

0 Answers0