TStringList of objects taking up tons of memory in Delphi XE

后端 未结 10 1449
遇见更好的自我
遇见更好的自我 2021-01-05 14:50

I\'m working on a simulation program.

One of the first things the program does is read in a huge file (28 mb, about 79\'000 lines,), parse each line (about 150 field

10条回答
  •  说谎
    说谎 (楼主)
    2021-01-05 15:39

    • In Delphi 2007 (and earlier), a string is an Ansi string, that is, every character occupies 1 byte of memory.

    • In Delphi 2009 (and later), a string is a Unicode string, that is, every character occupies 2 bytes of memory.

    AFAIK, there is no way to make a Delphi 2009+ TStringList object use Ansi strings. Are you really using any of the features of the TStringList? If not, you could use an array of strings instead.

    Then, naturally, you can choose between

    type
      TAnsiStringArray = array of AnsiString;
      // or
      TUnicodeStringArray = array of string; // In Delphi 2009+, 
                                             // string = UnicodeString
    

提交回复
热议问题