Back in October,
Borland® announced a new version of
Delphi®. ‘Delphi 2006’, codename Dexter, looks like it is going to contain a number of significant fixes and enhancements. These enhancements look like they will greatly enhance
Delphi®’s rapid application development (
RAD) environment.
FASTMM is an opensource replacement memory manager for
Borland® Delphi® (
Thanks Pierre for an excellent project!). Not only does it noticeably increase speed, but it also assists with the debugging and logging of memory leaks.
FASTMM discussions have been circulating for a while. Discussions about and attention to FASTMM have recently increased with the
indications that
FASTMM will be included in the next
Delphi® release.
My curiosity was peaked, and I started working with
FASTMM over the past week. I must admit that I am impressed. I am also excited to see how it will integrate with the newest release of
Delphi®. I started working with some small applications to get the feel for its usage and functionality. In one of my tests I dropped a
TShellComboBox, TShellListView and
TShellListView from the
Samples palette onto a
TForm and ran the application. Much to my surprise, I received
FASTMM notification of memory leaks when I closed the application. Considering I hadn’t written one line of code, I must admit I was skeptical of the leak. In order to give myself piece of mind (and boost confidence in
FASTMM) I decided to look through
ShellCtrls.pas to see if anything stood out. I also searched the web and
QualityCentral (
QC) to see if there were any fixes or posts discussing memory leaks with theses sample controls. I did find some old posts and fixes, however none related to my situation.
In reviewing
ShellCtrls.pas I did notice a few things that potentially validated the memory leaks noted by FASTMM. I changed some code (listed below), recompiled and reran my sample application. I was pleasantly surprised to see that the dialog box (that causes your heart to drop) displaying memory leak information no longer appeared. I consider this my indoctrination to using FASTMM. Thus far I am very pleased with it and look forward to the continued use of this excellent memory manager.
The changes I made to
ShellCtrls.pas:
In TCustomShellTreeView add:
public
destructor Destroy; override;
destructor TCustomShellTreeView.Destroy;
begin
if Assigned(FRootFolder) then
FRootFolder.Free;
inherited;
end;
In TCustomShellListView change:
destructor TCustomShellListView.Destroy;
begin
ClearItems;
FFolders.Free;
inherited;
end;
to
destructor TCustomShellListView.Destroy;
begin
ClearItems;
FFolders.Free;
if Assigned(FRootFolder) then
FRootFolder.Free;
inherited;
end;
In TCustomShellComboBox change:
destructor TCustomShellComboBox.Destroy;
begin
inherited Destroy;
if Assigned(FImageList) then FImageList.Free;
end;
to
destructor TCustomShellComboBox.Destroy;
var
i: integer;
begin
for i := 0 to Items.Count - 1 do
if Assigned(Folders[i]) then Folders[I].Free;
if assigned(FRootFolder) then FRootFolder.Free;
inherited Destroy;
if Assigned(FImageList) then FImageList.Free;
end;
Labels: Code, Delphi, Fixes, WIN32