OutOfMemoryError with TStringList

I am trying to populate a string list with streamreader. But I have an OutOfMemoryError when populating it. I am searching the Internet, but I will find something about a solution. I am also trying to increase the capacity of the list of strings, but nothing changes. Thank you for your help.

Here is my code:

list := TStringList.create; //list.Capacity := 100000000; Doesn't work Reader := TStreamReader.Create(filename, true); try list.BeginUpdate; try list.Clear; while not Reader.EndOfStream do list.Add(Reader.ReadLine); // OutOfMemoryError finally list.EndUpdate; end; finally Reader.Free; end; 

I forgot that the xml file size is 250 m.

+5
source share

Source: https://habr.com/ru/post/1233705/


All Articles