Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Forms and memory

I have a project with several forms and a menu making them all accessible. When a user clicks on a menu item a form opens. Now, when the user clicks on another menu item I close the form (actually I use caHide) and open the new form. I know that caHide does not free the memory associated with the hidden form but if I use caFree then I get an error if the user tries to return to the form. I'm worried that I will have too many forms running simultaneously and run out of memory. Is there a way of closing a form, and freeing the memory associated with it, but still allowing the form to be accessible?
Thanks in advance for any help.

Comments

  • zibadianzibadian Member Posts: 6,349
    : I have a project with several forms and a menu making them all accessible. When a user clicks on a menu item a form opens. Now, when the user clicks on another menu item I close the form (actually I use caHide) and open the new form. I know that caHide does not free the memory associated with the hidden form but if I use caFree then I get an error if the user tries to return to the form. I'm worried that I will have too many forms running simultaneously and run out of memory. Is there a way of closing a form, and freeing the memory associated with it, but still allowing the form to be accessible?
    : Thanks in advance for any help.
    :
    You need to remove the form from the Auto-create forms in the project options. Then you need to write the code to create the form manually each time the form needs to be shown. This code is not as hard as it sounds:
    [code]
    Form2 := TForm2.Create(Application);
    [/code]
    From then on you can use Form2 like you normally did. After the user is done with the form, you can free it again.
  • Jimi HendrixJimi Hendrix Member Posts: 9
    Thanks again for your help. Managed to sort it.
    : : I have a project with several forms and a menu making them all accessible. When a user clicks on a menu item a form opens. Now, when the user clicks on another menu item I close the form (actually I use caHide) and open the new form. I know that caHide does not free the memory associated with the hidden form but if I use caFree then I get an error if the user tries to return to the form. I'm worried that I will have too many forms running simultaneously and run out of memory. Is there a way of closing a form, and freeing the memory associated with it, but still allowing the form to be accessible?
    : : Thanks in advance for any help.
    : :
    : You need to remove the form from the Auto-create forms in the project options. Then you need to write the code to create the form manually each time the form needs to be shown. This code is not as hard as it sounds:
    : [code]
    : Form2 := TForm2.Create(Application);
    : [/code]
    : From then on you can use Form2 like you normally did. After the user is done with the form, you can free it again.
    :

Sign In or Register to comment.