Basically, there is no limit to the size of an ini file or the routine GetPrivateProfileString
(which is used by TIniFile
to read the data).
But there are some limits and things to consider when using TIniFile
.
Looking into the code of the TIniFile
implementation (thank you Delphi), there are several places where GetPrivateProfileString
is used to retrieve data from an ini file.
In TIniFile.ReadString
the buffer size is fixed to 2048 (2k) for reading string values.
As all other 'value' requesting routines use this routine to actually read the data from the inifile, it basically limits the buffer size for all those routines.
Second, the TIniFile.ReadSections
routine uses a starting buffer of 16384 (16k) characters. But when this buffer is too small it uses a dynamic buffer which is based on the file size, so this way you won't run into a buffer problem (but because this actually reads the entire file to estimate the buffer size, this will be very slow with large ini files).
Last, the TIniFile.ReadSection
routine, which uses an initial buffer size of 1024 (1k). But dynamically allocates a larger buffer when needed. So at this point, there also doesn't seem to be a limit to the (file)size.
NOTE: this information is based on Delhi 10.3 and Delphi XE2.
In older versions there we're other buffer allocation strategies...
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…