Конференция "KOL" » "memory hoarding" problem [Delphi, Windows]
 
  • jarek (03.03.09 17:50) [0]
    Hi all,
    I have problem with this code:
    program FormsTest;

    uses
     KOL;

    type
     PForm1 = ^TForm1;
     TForm1 = object(TObj)
     Form: PControl;
    public
     procedure FrmClick(Sender: PObj);
    end;

    var
     Form1: PForm1;

    procedure NewForm1(var Result: PForm1; AParent: PControl);
    begin
     New(Result,Create);
     with Result^ do
     begin
       Form := NewForm(AParent,'Form1').SetSize(320,240);
       Form.OnFormClick := FrmClick;
     end;
    end;

    procedure TForm1.FrmClick(Sender: PObj);
    var
     NewForm: PForm1;
    begin
     NewForm1(NewForm,Applet);
     NewForm.Form.Show;
     NewForm.Free;
    end;

    begin
     Applet := NewApplet('Forms Test');
     NewForm1(Form1,Applet);
     Run(Applet);
    end.


    Application takes  after start 3108 kB of memory.
    When I click on the form, new window opens and application takes more of memory. If I close this new window, the usage of RAM not changes.
    If I open 100 new windows, application takes 3376 kB of RAM. If I close all new windows, application still takes 3376 kB of RAM.
    Can anybody help me?
    Thanks. jarek
  • Дмитрий К © (03.03.09 20:35) [1]
    in NewForm1
    Form := NewForm( ...
    Form.Add2AutoFree(Result);

  • Jon © (03.03.09 22:01) [2]
    Also make use of
    SetProcessWorkingSetSize(GetCurrentProcess,Cardinal(-1),Cardinal(-1));


    at convenient places, such as after freeing form.
 
Конференция "KOL" » "memory hoarding" problem [Delphi, Windows]
Есть новые Нет новых   [134431   +15][b:0][p:0.001]