Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7159577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:15:14+00:00 2026-05-28T13:15:14+00:00

My application spawns several independent forms. Once when created the application forgets about them.

  • 0

My application spawns several independent forms. Once when created the application forgets about them. All action is handled in that form itself. When the application closes the form closes also, by the RTS i suppose. This is fine except that neither the OnClose nor the OnDestroy event are being fired, so memory leaks occur. I can administer which forms are present (as i do now) but actually the application must completely forget about these forms.

Is there a way to detect inside a form, being not the application main form, that the application is in the process of being closed?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T13:15:15+00:00Added an answer on May 28, 2026 at 1:15 pm

    The OnDestroy event certainly will fire if the form is destroyed. It’s invoked from the form’s destruction code. So the only conclusion is that your form is not being destroyed and so is leaked.

    There are a couple of obvious ways to make sure that your independent forms are not leaked:

    1. When you create then, pass either Application or MainForm as the owner parameter of the form. When the owner is destroyed, it will also destroy everything it owns, including your forms.
    2. Explicitly destroy these forms from, for example, the main form destructor or the .dpr file after the call to Application.Run returns.

    Option 1 is the most commonly used approach.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have an application that spawns multiple instances of a single win form.
I've created a Windows/C++/WTL application that spawns a child process. The two processes communicate
The Mac build of my (mainly POSIX) application spawns a child thread that calls
I have a C linux application (A) that spawns another process (P) when it
I am trying to make a service that spawns a desktop application, and then
I'm writing a windows service in C# that spawns multiple instances of another application
I have an application that spans several pages of engagement for the applicant and
I have a simple application with a manager thread that spawns ten simple worker
Right now, I have a full screen application which spawns several full screen JFrames
I have an MFC application that spawns a number of different worker threads and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.