Form not downloaded from memory

Asked

Viewed 731 times

3

Hello guys I need help. Dude form not downloaded from memory so I can’t call him again. Follows code below:

If formage=nil then
Begin

I create the form and no onclose of form

Action:=cafree:
Formage:=nil

Someone has an idea???

  • How do you create the Form? Or is it already loaded into memory when initializing the application? Another question, you open it with .Show or .ShowModal?

  • Then I create the form in run with tform.create (self) there I display with show pq with modal I cannot call another screen....

  • A very curious question, you are using fmx tool to develop Android applications?

  • Note the documentation of the Embarcadero (http://docwiki.embarcadero.com/Libraries/Tokyo/en/FMX.Forms.TForm.OnClose) that the caFree already releases the form memory. So I assume there’s something else wrong in the way that the Forms are being loaded into memory.

  • So we are creating it so formage:=tformage.create (self); formage.show; remembering q marked it to be created in Runtime....

2 answers

3

Remove from the procedure OnClose the two procedures informed. And after the display of the Form (which logically occurred after creation) you apply the destruction:

formage := Tformage.Create(Application);
formage.ShowModal;
FreeAndNil(formage);

Note that after the Display is called the detritus method! This is the correct way to control memory.Remembering that Delphi is weak in this management. That is, within the form formage you must control the creation and destruction of your variables.

  • The problem is if the programmer does not use ShowModal, then the memory release control has to be different.

  • Yes, without ShowModal he loses control, would have to implement a Timer and keep searching for Variable X to know if it’s time for the FreeAndNil(formage). That’s a lot of Gambiarra.

  • Then I cancel the onclose... and destroy with the free.... and it could not be with expense??

  • 1

    The correct is Freeandnil(object);

-3


People solved it like this:
The formage creates the formaux...in the formaux has a button who does what is necessary and calls again the formage.show; The formage back to the screen.... when I click on checkbox he checks again if the formaux is nil and flame again closing the cycle..

  • 1

    Your answer is very confusing, if you manage to improve the explanation will make it much easier if other users have the same question.

  • I came across the same problem and corrected it this way: https://answall.com/questions/254155/erro-criando-novas-telas-no-delphi-para-android/254277#254277

Browser other questions tagged

You are not signed in. Login or sign up in order to post.