Avoid using TDictionary

There are serious flaws in TDictionary in Delphi 2009. Try to avoid using it until a fixed version comes out. You can find a list of them in QC, but just to name two:

  1. TDictionary.Clear() is flawed. If you clear the dictionary and then try to add another item to it, you will get an AV.
  2. TDictionary.Add() is too slow. Adding 1000 elements in a Integer, Integer dictionary takes a few seconds.

There are probably more issues but these two are enough reason not to use TDictionary yet.

3 Comments

  1. I fully agree. I had some perhaps even more severe issues. What I did was “lazy counting” of strings, via TDictionary, inserting keys for new strings and incrementing the counter for existing ones. Generally, this lazy approach worked, but after heavy use in that mode, there were some damages in the data.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.