Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>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 <code>TStringList</code> instead of a <code>TList</code> or <code>TObjecList</code>. 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 <code>TDictionary</code> class in the <code>Generics.Collections</code> unit in XE.</p> <p>As for why you're using more memory in XE, it's because the <code>string</code> 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.</p> <p>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:</p> <ul> <li>Read the file into a TStringList. (This will use about as much memory as the file size. Maybe twice as much if it gets converted into Unicode strings.) Don't create any data objects.</li> <li>When you need a specific data object, call a routine that checks the string list and looks up the string key for that object.</li> <li>Check if that string has an object associated with it. If not, create the object from the string and associate it with the string in the TStringList.</li> <li>Return the object associated with the string.</li> </ul> <p>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.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload