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...
TMemIniFile
. – Andreas Rejbrand Jan 22 at 20:03TIniFile
itself does not impose any size limits. It is just a wrapper for the PrivateProfile API, so any limits will be in the OS itself. And according to Raymond Chen: "INI files are limited to 32KB in size", but that was 13 years ago. Maybe it has been upped since then. – Remy Lebeau Jan 22 at 21:57