Recent

Author Topic: TStringList limitations  (Read 926 times)

backprop

  • Full Member
  • ***
  • Posts: 101
TStringList limitations
« on: July 20, 2024, 12:37:43 pm »
https://www.freepascal.org/docs-html/rtl/classes/tstringlist.html

In Delphi, limitation is to  2,147,483,647 strings. I do not see that info here for Lazarus. The same or less?

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10546
  • Debugger - SynEdit - and more
    • wiki
Re: TStringList limitations
« Reply #1 on: July 20, 2024, 12:56:41 pm »
While it is not the same as documentation, you can just look it up in the sources.

The IDE takes you do the declaration of any method... Such as:
Code: Pascal  [Select][+][-]
  1. procedure TStringList.Insert(Index: Integer; const S: string);

"Integer" => same limit.

Assuming you have enough memory.

If you want to be extra careful, check the implementation, if it maybe one less, in case some code calculates "Index + 1" or something.



Also, that of course does not say, if the limit can be used by simply doing that many "Add".  (But then, I do not have Delphi, to check if it can do that...).

That depends on how Capacity grows, and if it will reach that final limit, or break before. But you can always set Capacity yourself to that value, and then the normal growth procedure wont interfere.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10546
  • Debugger - SynEdit - and more
    • wiki
Re: TStringList limitations
« Reply #2 on: July 20, 2024, 01:04:04 pm »
Also mind, "if you have enough memory" also implies: If a single large enough block can be allocated.

Large enough to hold all the strings (not their text, but the variable that is the internal pointer).

On a 32bit system, that will never be the case. It wont be in Delphi either.  A 32 bit CPU can't address enough memory to do that. So the hardware puts a limit on that.

On 64bit platform that should be possible, and amount to approximately 32 GB of continuous memory  (not including the text, or the metadata, that allocate extra memory blocks / unless all your strings are empty)

One string entry in the list has 8 bytes. But there is an entry for the object that can be stored. so 16 bytes per entry. 16 * 2,147,483,647

Thaddy

  • Hero Member
  • *****
  • Posts: 16147
  • Censorship about opinions does not belong here.
Re: TStringList limitations
« Reply #3 on: July 20, 2024, 04:56:29 pm »
https://www.freepascal.org/docs-html/rtl/classes/tstringlist.html

In Delphi, limitation is to  2,147,483,647 strings. I do not see that info here for Lazarus. The same or less?
Where did you get that from, because that is - of course in your case always- wrong. It should be two GB and with the proper flag set 4GB - closer to 3GB in practice- on 32 bit and that is storage - memory - not lines.
Programming like that is a horror, by the way.
You should not even attempt to try that.
« Last Edit: July 20, 2024, 04:59:34 pm by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10546
  • Debugger - SynEdit - and more
    • wiki
Re: TStringList limitations
« Reply #4 on: July 20, 2024, 05:05:08 pm »
Where did you get that from,

Well, I don't know where he got it from, but if I were taking a guess: The relevant documentation? According to google: http://docwiki.embarcadero.com/Libraries/Athens/en/System.Classes.TStringList
Quote from: http://docwiki.embarcadero.com/Libraries/Athens/en/System.Classes.TStringList
TStringList can contain up to 2,147,483,647 strings. This is because the list is indexed using an integer. See String Types (Delphi) for information about the size limit of each string.

Never mind the quality of that info...

backprop

  • Full Member
  • ***
  • Posts: 101
Re: TStringList limitations
« Reply #5 on: July 20, 2024, 07:10:42 pm »
Where did you get that from, because that is - of course in your case always- wrong. It should be two GB and with the proper flag set 4GB - closer to 3GB in practice- on 32 bit and that is storage - memory - not lines.
Programming like that is a horror, by the way.
You should not even attempt to try that.

Taddy, you are complete ignorance and if you do not know, better be quiet.
 Read Emarcadero site.

Locked.

 

TinyPortal © 2005-2018