1

Regarding: Delphi, VirtualStringTree - classes (objects) instead of records

Does the memory increases or something?

PS: I am using Delphi 2007.

Community
  • 1
  • 1
Luis Carrasco
  • 467
  • 3
  • 10

1 Answers1

2

There are two drawbacks to using objects instead of records. First, each object is 4 bytes larger than a record containing the same data would be. (Or 8 bytes, from D2009 on.)

Second, an object has to be created and destroyed; it's not "just there" the way a record is. But from the other question, it looks like your records have to be referred to through pointers anyway, so that's not much of a difference. You'd still have to dynamically allocate your records and free them later.

But if you use an object you gain a lot of extra flexibility, especially the ability to use inheritance and polymorphism. It's definitely worth the extra 4 bytes.

Uwe Raabe
  • 45,288
  • 3
  • 82
  • 130
Mason Wheeler
  • 82,511
  • 50
  • 270
  • 477
  • Since much focus of VirtualStringTree goes into speed I suspect the "not having to create and destroy" part is the biggest reason. – Lars Truijens Apr 21 '10 at 07:29