I created a simple application with a button on a form Tform1 which is used to create another form Tform2. Form2 contains a toolbar with 2 buttons at each corner and a label with a tabcontrol below it. I keep getting this memory leak below. Im sure i created and destroyed the forms correctly.
program Project1;
uses
System.StartUpCopy,
FMX.Forms,
Unit1 in 'Unit1.pas' {Form1},
Unit2 in 'Unit2.pas' {Form2};
{$R *.res}
begin
ReportMemoryLeaksOnShutdown := True;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
here is the form1 that creates the form2
unit Unit1;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
FMX.Controls.Presentation, FMX.StdCtrls, Unit2;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
procedure TForm1.Button1Click(Sender: TObject);
begin
Hide;
Application.CreateForm(TForm2, Form2);
Form2.Show;
Form2.WindowState := TWindowState.wsMaximized;
end;
end.
Form 2 with the toolbar and tabcontrol
unit Unit2;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls,
FMX.TabControl, FMX.Controls.Presentation;
type
TForm2 = class(TForm)
ToolBar1: TToolBar;
Button1: TButton;
TabControl1: TTabControl;
TabItem1: TTabItem;
TabItem2: TTabItem;
Label1: TLabel;
Button2: TButton;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.fmx}
procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := TCloseAction.caFree;
// ShowMessage('Form Freed now closing whole application') ;
Application.MainForm.Close;
end;
end.