I\'m working on a simulation program.
One of the first things the program does is read in a huge file (28 mb, about 79\'000 lines,), parse each line (about 150 field
It's hard to say why your 28 MB file is expanding to 1.4 GB worth of objects when you parse it out into objects without seeing the code and the class declarations. Also, you say you're storing it in a TStringList
instead of a TList
or TObjecList
. This sounds like you're using it as some sort of string->object key/value mapping. If so, you might want to look at the TDictionary
class in the Generics.Collections
unit in XE.
As for why you're using more memory in XE, it's because the string
type changed from an ANSI string to a UTF-16 string in Delphi 2009. If you don't need Unicode, you could use a TDictionary to save space.
Also, to save even more memory, there's another trick you could use if you don't need all 79,000 of the objects right away: lazy loading. The idea goes something like this:
This will keep both your memory usage and your load time down, but it's only helpful if you don't need all (or a large percentage) of the objects immediately after loading.