Page MenuHomeFeedback Tracker

FGets( The problem with reading the content )
Assigned, NormalPublic

Description

The FGets function, when reading a mediocre file, works extremely slowly, up to the point of freezing the client and (or) the server.
For example, create a file with more than 100,000 lines.

The problem is exactly in this place:
v_Content += v_buffer;

Details

Severity
None
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
Engine
Steps To Reproduce
void TestReadFile()
{
	int			v_LinesCount	=	0;
    string 		v_Buffer;
	string 		v_Content;
	FileHandle	v_File			=	OpenFile( "$profile:test.txt", FileMode.READ );

	while ( FGets( v_File,  v_Buffer) > 0 )
	{     
		v_Content	+= v_Buffer;
		v_LinesCount++;
	}
	CloseFile( v_File );
	Print( v_LinesCount.ToString() );
}
Additional Information

For example, the same code in Delphi, with the Pascal method.
The reading speed is less than 1 second!

Procedure TestReadFile();
Var
    F            : TextFile;
    B            : String;
    Content        : String;
    LinesCount    : Integer;
Begin
    AssignFile( F, "test.txt" );
    Reset( F );
    LinesCount := 0;
    While not EOF( F ) do
    Begin
        ReadLn( F, Buffer );
        Content := Content + Buffer;
        inc( LinesCount );
    end;
    CloseFile( F );
    ShowMessage( IntToStr( LinesCount ) );
end;

*In DayZ, when reading a file of more than 500,000 lines, DayZ hangs.( Waiting for more than 15 minutes did not lead to anything ).
For example ~60 000 lines
SCRIPT : START: 20:25:57
SCRIPT : END: 20:26:14

For example ~120 000 lines
SCRIPT : START: 20:27:02
SCRIPT : END: 20:28:01

For example ~500 000 lines
Waiting for more than 5 minutes did not give anything. The server is hanging

Event Timeline

NoNameUltima edited Additional Information. (Show Details)
NoNameUltima edited Additional Information. (Show Details)Mar 24 2024, 6:36 PM
NoNameUltima renamed this task from FGets to FGets( The problem with reading the content ).Mar 24 2024, 7:37 PM
NoNameUltima updated the task description. (Show Details)
Geez changed the task status from New to Assigned.Mar 25 2024, 10:59 AM