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

  • Home
  • SEARCH
  • 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 32387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T13:45:18+00:00 2026-05-10T13:45:18+00:00

In one of my VB6 forms, I create several other Form objects and store

  • 0

In one of my VB6 forms, I create several other Form objects and store them in member variables.

Private m_frm1 as MyForm Private m_frm2 as MyForm  // Later... Set m_frm1 = New MyForm Set m_frm2 = New MyForm 

I notice that I’m leaking memory whenever this (parent) form is created and destroyed. Is it necessary for me to assign these member variables to Nothing in Form_Unload()?

In general, when is that required?

SOLVED: This particular memory leak was fixed when I did an Unload on the forms in question, not when I set the form to Nothing. I managed to remove a few other memory leaks by explicitly setting some instances of Class Modules to Nothing, as well.

  • 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. 2026-05-10T13:45:18+00:00Added an answer on May 10, 2026 at 1:45 pm

    @Matt Dillard – Did setting these to nothing fix your memory leak?

    VB6 doesn’t have a formal garbage collector, more along the lines of what @Konrad Rudolph said.

    Actually calling unload on your forms seems to me to be the best way to ensure that the main form is cleaned up and that each subform cleans up their actions.

    I tested this with a blank project and two blank forms.

    Private Sub Form_Load()   Dim frm As Form2   Set frm = New Form2   frm.Show   Set frm = Nothing End Sub 

    After running both forms are left visible. setting frm to nothing did well… nothing.

    After settign frm to nothing, the only handle open to this form is via the reference.

    Unload Forms(1) 

    Am I seeing the problem correctly?

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

Sidebar

Related Questions

There are two vb6 applications that I work with. One of them starts up
I have a Calendar control on a VB6 form which on one machine is
I need to create a captionless but one-side moveable WinForms form. Is it possible?
I'm porting an old VB6 app into .Net but one Vb6 form is too
Is there a good way to create a form in VB6 that can easily
I have an ASP Classic application which references some VB6 COM OBJECTS. One of
I am converting an application originally written in vb6 to vb.net. One of the
Some background: I'm a jack-of-all trades, one of which is programming. I learned VB6
one question about PHP Development. I am building up some Form Fields for Calculations.
One of the possible forms of template parameter is a class template. The C++

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.