I'm using this code to change how items are shown on a TListView
at runtime:
// lvContacts: TListView
// cdsContacts: TClientDataSet with two records
// lcfContacts: TLinkListControlToField
lvContacts.Items.BeginUpdate;
dmLocalData.cdsContacts.DisableControls;
try
lcfContacts.FillExpressions.Clear;
if MultiDetailsView then
begin
lvContacts.ItemAppearance.ItemAppearance := 'MultiDetailItem';
with lcfContacts.FillExpressions.AddExpression do
begin
SourceMemberName := 'PictureData';
ControlMemberName := 'Bitmap';
end;
with lcfContacts.FillExpressions.AddExpression do
begin
SourceMemberName := 'Job';
ControlMemberName := 'Detail';
end;
with lcfContacts.FillExpressions.AddExpression do
begin
SourceMemberName := 'email';
ControlMemberName := 'Detail1';
end;
with lcfContacts.FillExpressions.AddExpression do
begin
SourceMemberName := 'mobilePhone';
ControlMemberName := 'Detail2';
end;
with lcfContacts.FillExpressions.AddExpression do
begin
SourceMemberName := 'landLinePhone';
ControlMemberName := 'Detail3';
end;
end else begin
lvContacts.ItemAppearance.ItemAppearance := 'ImageListItemBottomDetail';
with lcfContacts.FillExpressions.AddExpression do
begin
SourceMemberName := 'PictureData';
ControlMemberName := 'Bitmap';
end;
with lcfContacts.FillExpressions.AddExpression do
begin
SourceMemberName := 'Job';
ControlMemberName := 'Detail';
end;
end;
finally
lvContacts.Items.EndUpdate;
dmLocalData.cdsContacts.EnableControls;
end;
I monitored my application on an iPhone with Instruments, and I see about 1 gigabyte of leaked TMoveArrayManager
instances every time this code is executed. After only a few times, my iPhone runs out of memory and shuts down my application. I tried to find a better way to dispose of and create live bindings at run-time, but couldn't come up with a better solution. Has anyone ever had such a problem with live bindings?