• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 393
  • Last Modified:

form load unload /memory management

I hawe application with many forms which using graphics and large data array
I hawe following question can I load form before i wont to use it and after that to unload it from memory so i can manage my memory resources ?
Form shold be later aviable for load / unload again


I'm not sure how delphi manage memory resources so I'm affraid if i write to many forms with larege memory request's it can slow down my app

Das show/hide relase memory which form use ?

Regards
0
monster2
Asked:
monster2
  • 3
  • 2
  • 2
  • +2
1 Solution
 
monster2Author Commented:
Is better method to borke programs in separate exe which can call each other ?
If so how can I transfer variables betwean exe files (not using some sort of temp temp files)
0
 
RBertoraCommented:
Show hide does not release memory..

You have to use CreateForm, and From1.Free for
propery memory management.

Rob ;-)
0
 
simonetCommented:
What you can do is:

- From the Project -> Options -> Forms, remove all but the main form and datamodules from the AutoCreate list of forms. Only leave there the forms you REALLY need at your applications's startup.

- Now, in order to create a form at runtime, add the unit where the form is to the implementation's uses clause of the unit that must create that form.

To have form1 Create and destroy form2, you'll have this scenario:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses Unit2;

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
      Form2 := TForm2.create(application);
  form2.show; { or Form2.showmodal... up to you }
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
      Form2.close;
end;

end.


Yours,

Alex



0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
rwilson032697Commented:
Of course, you would also add Action := caFree in the OnClose event of the dynamically created form, or call Form2.Release to destroy the form. :-)

Cheers,

Raymond,
0
 
rwilson032697Commented:
Of course, you would also add Action := caFree in the OnClose event of the dynamically created form, or call Form2.Release to destroy the form. :-)

Cheers,

Raymond,
0
 
simonetCommented:
Right!

Monster2, as long as you free the other forms before creating them again, you can create and destroy them as many times as your want.

Alex
0
 
monster2Author Commented:
If i stuck again with this i know where to cry for help

Thanks people & regards

0
 
monster2Author Commented:
If i stuck again with this i know where to cry for help

Thanks people & regards

0
 
MoondancerCommented:
This question was awarded, but never cleared due to the JSP-500 errors of that time.  It was "stuck" against userID -1 versus the intended expert whom you awarded.  This corrects the problem and the expert will now receive these points; points verified.

Please click on your Member Profile and select "View Question History" to navigate through any open or locked questions you may have to update and finalize them.  If you are an EE Pro user, you can also choose Power Search to find all your open questions.

This is the Community Support link, if help is needed, along with the link to All Topics which reflects many TAs recently added.

http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
http://www.experts-exchange.com/jsp/zonesAll.jsp
 
Thank you,
Moondancer
Moderator @ Experts Exchange
0

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

  • 3
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now