I have an old game written in delphi and the game keeps crashing, the game is an mmorpg so there are constantly people online.

To the problem, when we first start the game up, everyone can get on fine and play. The game stores variables into text files for each character whenever called by a script using the WriteString/WriteInteger function from TIniFiles.

Now the game will run no problem for around 8 hours, saving 1000's of variables. But after a while, it just dies, and constantly reports the 'Unable to write to file' error for the variables.

Just wondering if anyone has had any pervious experience which releates to this problem.

Many thanks.

Hi, Let's start with this quote,

Use TMemIniFile to store and retrieve application-specific information and settings in a Windows INI file. The INI file text format, introduced in Windows 3.x, lets applications store and retrieve settings from session to session. An INI file stores information in logical groupings, called “sections.” For example, the WIN.INI file contains a section called “[Desktop]”. Within each section, actual data values are stored in named keys. Keys take the form:

<keyname>=<value>

Unlike the TIniFile object, which also encapsulates INI file data, TMemIniFile buffers all changes to the INI file. The INI file is read once, when the object is first created. Data from the INI file is stored in nested string lists. Each section in the INI file occupies one element in the top-most string list, and each element in this may itself contain a string list. Each element in each of the contained string list represents a key within the section. After the data is read, any changes to the data are stored in memory. To write the data from memory back to the associated INI file, call the UpdateFile method.

All TMemIniFile methods to read, write, and erase sections, keys, and values operate on the in-memory copy of the INI file.

This buffering of INI file data is important under the Windows NT environment, where INI file writes are not buffered. In applications where there is a significant amount of reading from or writing to an INI file, this buffering prevents degradation of the application’s performance.

The FileName passed to a TIniFile object when it is created is the name of the INI file the object accesses. Because DelphiC++Builder, and not the operating system, writes the data to the INI file, saving data changes is faster in all supported versions of Windows.

This is directly out of the CBuilder help files (all CBuilder components are written in Delphi and pascal so no biggy there). The TIniFile component locks the ini file as it reads and then writes updates to it. In older stuff timing was not an issue as everything ran so ssssssssslow. I think you have reached the limit of (1) file size on the OS or (2) with new fast machines the bigger the file gets the more chances you have of a collision between someone writing to the ini and someone else wanting to amd hitting a access denied time out. Just my 2¢.
magik

Inifiles have a size limit of 32 to 64k...check out the filesize...I would bet your running up against this...I would suggest moving to some type of database system to save the info...There are lots of free alternatives...If this is server based...check out MySQL or FireBird

You might want to try SQLite, a serverless, fast, file-based database. It's ideal to replace a large INI file.

This article has been dead for over six months. Start a new discussion instead.