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 4018248
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:57:36+00:00 2026-05-20T09:57:36+00:00

I have a main window in my project, and numerous other child widows inside

  • 0

I have a main window in my project, and numerous other child widows inside the main.
I have noticed that. When I open the main window occupies 1500K of memory, when open one child window then adds in occupied memory 6000K.
When I open the second window doing the same. When I close the two child windows the occupied memory is not released.
So What I want is to release the occupied memory when ever I close child windows.
How I can do that?
Please advice me with some code example in vb.net if it is possible.
This problem often sawing in the computers on the Local NET not in my computer (developer computer which has the SQL server on it).

  • 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-20T09:57:37+00:00Added an answer on May 20, 2026 at 9:57 am

    Using as suggested by Pranay will work as it will by default call Dispose method. else explicitly you have to call this.dispose() after calling this.close() on your child forms. But be sure you are not going to use child form elements or value after close. Since dispose will finally clear everything.

    MSDN example for disposing unmanaged resource

    Imports System
    Imports System.ComponentModel
    
    ' The following example demonstrates how to create
    ' a resource class that implements the IDisposable interface
    ' and the IDisposable.Dispose method.
    Public Class DisposeExample
    
       ' A class that implements IDisposable.
       ' By implementing IDisposable, you are announcing that 
       ' instances of this type allocate scarce resources.
       Public Class MyResource
          Implements IDisposable
          ' Pointer to an external unmanaged resource.
          Private handle As IntPtr
          ' Other managed resource this class uses.
          Private component As component
          ' Track whether Dispose has been called.
          Private disposed As Boolean = False
    
          ' The class constructor.
          Public Sub New(ByVal handle As IntPtr)
             Me.handle = handle
          End Sub
    
          ' Implement IDisposable.
          ' Do not make this method virtual.
          ' A derived class should not be able to override this method.
          Public Overloads Sub Dispose() Implements IDisposable.Dispose
             Dispose(True)
             ' This object will be cleaned up by the Dispose method.
             ' Therefore, you should call GC.SupressFinalize to
             ' take this object off the finalization queue 
             ' and prevent finalization code for this object
             ' from executing a second time.
             GC.SuppressFinalize(Me)
          End Sub
    
          ' Dispose(bool disposing) executes in two distinct scenarios.
          ' If disposing equals true, the method has been called directly
          ' or indirectly by a user's code. Managed and unmanaged resources
          ' can be disposed.
          ' If disposing equals false, the method has been called by the 
          ' runtime from inside the finalizer and you should not reference 
          ' other objects. Only unmanaged resources can be disposed.
          Protected Overridable Overloads Sub Dispose(ByVal disposing As Boolean)
             ' Check to see if Dispose has already been called.
             If Not Me.disposed Then
                ' If disposing equals true, dispose all managed 
                ' and unmanaged resources.
                If disposing Then
                   ' Dispose managed resources.
                   component.Dispose()
                End If
    
                ' Call the appropriate methods to clean up 
                ' unmanaged resources here.
                ' If disposing is false, 
                ' only the following code is executed.
                CloseHandle(handle)
                handle = IntPtr.Zero
    
                ' Note disposing has been done.
                disposed = True
    
             End If
          End Sub
    
          ' Use interop to call the method necessary  
          ' to clean up the unmanaged resource.
          <System.Runtime.InteropServices.DllImport("Kernel32")> _
          Private Shared Function CloseHandle(ByVal handle As IntPtr) As [Boolean]
          End Function
    
          ' This finalizer will run only if the Dispose method 
          ' does not get called.
          ' It gives your base class the opportunity to finalize.
          ' Do not provide finalize methods in types derived from this class.
          Protected Overrides Sub Finalize()
             ' Do not re-create Dispose clean-up code here.
             ' Calling Dispose(false) is optimal in terms of
             ' readability and maintainability.
             Dispose(False)
             MyBase.Finalize()
          End Sub
       End Class
    
       Public Shared Sub Main()
          ' Insert code here to create
          ' and use the MyResource object.
       End Sub
    
    End Class
    

    (Update)[Check]

    If your child form has the signature. These are by default added to a form.

    'Form overrides dispose to clean up the component list.
        Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
            If disposing Then
                If Not (components Is Nothing) Then
                    components.Dispose()
                End If
            End If
        MyBase.Dispose(disposing)
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a main window, that opens another window. I want to close this
I have a main window where all the work is done. When i open
i have a mvvm app that the main window is a tab control. i
I have an application with a main window that loads in text file(s) and
I have a WPF project and the main window is required to have rounded
I have a very strange issue in my WPF project. The main window contains
I was working on a WPF project today that had a main nav window
In the current project we work on, we have a main window with several
I have create a project with one main form window and also i have
I have main window which has inner grid components. When I press a button

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.