function TEMISLogic.UpdateMenu(var OldFields: TEMISFields): Boolean;
begin
Result := False;
try
Result := FEMISS.UpdateMenu(OldFields);
except
on E : Exception do
begin
FEMISCommon.ErrorDlg(e.Message);
Exit;
end;
end;
end;
begin
Result := False;
try
Result := FEMISS.UpdateMenu(OldFields);
except
on E : Exception do
begin
FEMISCommon.ErrorDlg(e.Message);
Exit;
end;
end;
end;
参数中TEMISFields为RemObject的Array类型,程序运行没有任何问题一切OK,但就是有内存泄漏,一直找原因就是找不到,后来突发奇想,再添一个变量代码如下
function TEMISLogic.UpdateMenu(var OldFields: TEMISFields): Boolean;
var
Fields: TEMISFields;
begin
Result := False;
try
Fields := OldFields;
Result := FEMISS.UpdateMenu(Fields);
FreeAndNil(Fields);
except
on E : Exception do
begin
FEMISCommon.ErrorDlg(e.Message);
Exit;
end;
end;
end;
红色部分是后来添加的,没想到这样就解决了内存泄漏,不知道有没有高手跟我说说原因。
var
Fields: TEMISFields;
begin
Result := False;
try
Fields := OldFields;
Result := FEMISS.UpdateMenu(Fields);
FreeAndNil(Fields);
except
on E : Exception do
begin
FEMISCommon.ErrorDlg(e.Message);
Exit;
end;
end;
end;