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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:22:38+00:00 2026-06-18T16:22:38+00:00

I built a project where in one form (frmDash) I add several forms as

  • 0

I built a project where in one form (frmDash) I add several forms as controls in a container.

frmChart.TopLevel = False
frmChart.FormBorderStyle = False
frmChart.ControlBox = False
container.Controls.Add(frmChart)

When I close the frmDash the memory is decreased but not as much as it expected.
So every time that I reopen the frmDash the memory is increased in relation with the previous time that it was opened.
When I close the frmDash :

For each frm as frmChart in container.Controls
   frm.Close
Next

container.Controls.Clear
container.Dispose

And in frmChart dispose method I dispose everything that I have (datatables, lists, charts -I know that I shouldn’t dispose some of those , but I am trying to find what is wrong).
Does anyone knows what I am doing wrong?

I found this here:
I also want to mention that, DataSet.Clear() and DataSet.Dispose() won’t make the rows cleared by GC. .Clear() method will remove all the data rows in every datatable inside the dataset. However, it does not remove the tables and relationships. Also, the .Dispose() method is implemented by the base class of the DataSet MarshalByValueComonent, so it does not release the managed resources of dataset.

To let GC clear all the datatable and datarows, please set the ds to null so all the managed resource of the original dataset are not referred and GC can finally clear them all. Another method is using DataSet.Reset, so the dataset will be at the initialized status without any tables or relationships added.

If that is true, I have to set every datatable to nothing because right know I just disposing it.

I did that, and I set every datatable that I used equal to nothing , but the memory leakage remains.

  • 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-06-18T16:22:39+00:00Added an answer on June 18, 2026 at 4:22 pm

    If you create any event handlers to the controls, these also need to be released. .Net’s GC will scan it’s object to look for a link to the object. Calling dispose will stop you from being able to reference the object but if there is an event handler still attached, the GC thinks that the event could still be raised.

    In VB.Net you can do

    RemoveHandler frmChart.Load, AddressOf ControlLoad
    

    This will then allow the GC to remove the object from memory.

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

Sidebar

Related Questions

I have built a system for my final year project. At one part, I
I want to add a collapse/expand capability to a Windows Form. Is this built
I was requested to built this project in JSP and one stipulation is that
I have two projects.One project is build in MVC asp.net and the other project
I need to build a solution, but exclude one project. How should I do
I have a website project that I want to build using CruiseControl.net. On one
I built a project in Eclipse for my BlackBerry. The jar cannot run on
So I built my project and I have a .app file from my BUILD
I have a new c++ project built with autoconf, automake and libtool. Functionality is
Does anybody have an experiencing with refactoring a project built with Xcode 4.3 down

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.