Delphi 2006 Win32 Run Time Library
In Delphi 2006 there are several interesting new features in the Win32 Run Time Library (RTL). The most relevant is with no doubt the introduction of a new memory manager, FastMM. This new memory manager is used by the IDE itself and is now also the default memory manager for the Delphi compiler applications. When you reopen an existing Delphi project in Delphi 2006 and recompile it you'll automatically have the new memory manager in action (unless you previously replaced the standard memory manager with a custom one in the project).
Beside the new memory manager, there are also many optimized RTL functions, some of which are coming from the FastCode project, while others relate to unit checks made on package loading.
FastMM
The new memory managed is called FastMM4 and has been developed as an open source project mainly by Pierre La Riche, a Delphi programmer from South Africa. FastMM4 optimizes the allocation of memory, speeding it up and freeing more RAM for subsequent use (the traditional Delphi memory manager suffered from excessive memory fragmentation). This is even more true for multi-threaded applications. FastMM is also capable of doing more extensive memory checks on the effective memory clean-up, on the wrongful use of deleted objects, including interface based access to that data, on memory overwrites and on buffer overruns. It can also provide some feedback on the left-over objects, helping you track memory leaks.
Actually some of the more advanced features of FastMM are available in the full version of the library, not in the one that has been added to the Delphi RTL, which used the same engine but without some of the more advanced checks. This way Delphi ensures a better compatibility with existing applications and avoids adding powerful features that not all programmers will be able to master easily. In fact, when you enable all of the debug options of the full memory manager you might end up seeing errors that didn't show up with the traditional memory manager, including some double deletions, overruns, and too-late interface method calls.
As I mentioned, to use the new memory manager you don't have to do anything: Open a project in Delphi 2006 and recompile it. If you want to have the capabilities of the full version, though, you have to download its source code from:
http://fastmm.sourceforge.net
If you get the full version of FastMM (but also if you use the one already in Delphi) I hope you'll consider making a donation to the author, who built this terrific piece of software investing a large amount of time. Follow the instructions on the web site for details.
FastCode
FastMM4 has been picked by Borland for its technical qualities, but also because it resulted as the winner of the memory tests of the FastCode project. This is a group of Delphi programmers that define some tests suites for different function calls part of the RTL, trying to come up with the most optimized version. In some cases the implementation is written in Pascal, but in many others this is low-level assembly code.
As described in the section “FastCode in Delphi 2005” (page 157) of the printed book, some of these routines were already part of Delphi 2005. The RTL of Delphi 2006 adds many more, some of which are very significant as they are commonly used:
The assembly version of the Move procedure in the System unit.
The Pos function in the System unit.
The functions StrCopy, StrComp, CompareMem, UpperCase, and LowerCase of the SysUtils unit.
The PosEx function of the StrUtils unit, which has been recoded in assembly for improved efficiency.
The functions Power, ArcCos, and ArcSin of the Math unit, which have been overloaded depending on the type passed as parameter (Double, Single, o Extended) and are now implemented in assembly.
Other New RTL Features
Among the other features of the runtime library, there is a change in the checks for duplicated units that takes place when you load packages dynamically (not just in the IDE, but also in your own applications). In the past this was based on a linear search in a list, now it uses a hash table. You can even disable this check altogether for your own projects, but only do so if you are sure there are no duplicated unit names among different packages you load. This is mainly an IDE optimization shaving a lot of time out of the IDE startup.
Some of the classic RTL classes have new properties and some units have additional functions, including the following:
The Capacity property of the TCollection class (in the Classes unit), which modifies the Capacity field of the internal TList object used to implement the collection.
The StrictDelimiter Boolean property of the TStrings class(in the Classes unit) makes more stringent the use of the character set in the Delimiter property within a delimited text (DelimitedText).
The Filename property of the TFileStream class (of the Classes unit) keeps a copy of the name of the file the stream is attached to, file name that is passed as parameter to the class constructor.
The TWideStrings class (of the WideStrings unit) now has an enumerator. This unit includes also improved support for wide strings on the Win9x platform. The class has been updated with the most recent new features of the corresponding TStrings class (including the LineBreak and StrictDelimiter properties).
The WideStrUtils unit introduced in Delphi 2005 has been extended with many new functions including WStrMove, WStrCat, WStrScan, WStrComp, and WStrPos; there are also a ConvertStreamFromUTF8ToAnsi function, a WideLastChar function, a WideDequotedString function, and a WideAdjustLineBreaks function.
There is a new overloaded version of the ClassNameIs method of the TObject class.
The are two new functions in the SysUtils unit: ChangeFilePath and IsAssembly (which checks whether a DLL passed as parameter by name is a .NET assembly or a traditional Win32 DLL).