alancc
alancc

Reputation: 799

Do I need to free auto-created form in Delphi?

I set a form(not the main form) as auto-created in the project. It seems that I do not need to free it manually when the main form is destroyed. If I do so, then I will get "Invalid Pointer" error. I do not see any document mention that.

Upvotes: 0

Views: 117

Answers (1)

Remy Lebeau
Remy Lebeau

Reputation: 596537

All auto-created Form objects are owned by the TApplication object. It will free them for you when itself is freed. But if you want to free them yourself beforehand, it is safe to do so, provided you don't try to access them after you free them (which, it sounds like you are). When freed, they will remove themselves from the TApplication object so it does not try to free them again.

Upvotes: 1

Related Questions