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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:23:37+00:00 2026-05-13T15:23:37+00:00

I analyze a VB.NET project and there are some objects (child MDI form) that

  • 0

I analyze a VB.NET project and there are some objects (child MDI form) that are disposed, but not removed by the GC.

The MemoryProfiler analysis find, among others, the following:

“This instance is disposed and still
indirectly rooted by an EventHandler.
This often indicates that the
EventHandler has not been properly
removed and is a common cause of
memory leaks. The instances below are
directly rooted by EventHandler(s).
Investigate them to get more
information about this issue…”

Now, I try to figure out what should this mean and how to fix it.

I have a MDI form and a child form. The child form is not collected by the GC after a open/close, apparently because remains still (indirectly?) referenced by the MDIForm EventHandlerList…

What can it be and how do I to fix it?

I tried the fix recommended in this thread, because had a problem with the MDI reference in the PropertyStore, now this eliminated, but appeared the MDI EventHandlerList reference to the child form…

After some code analysis I observed some

AddHandler newMenu.Click, AddressOf ClickMenu

without preceding with RemoveHandler newMenu.Click, AddressOf ClickMenu. Could it be the main cause?

And, a propos, is the Handles

Private Sub ClickMenu(sender as Object, e as EventArgs) Handles newMenu.Click

better that

RemoveHandler newMenu.Click, AddressOf ClickMenu
AddHandler newMenu.Click, AddressOf ClickMenu

from the memory allocation point of view?

  • 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-13T15:23:38+00:00Added an answer on May 13, 2026 at 3:23 pm

    The EventHandlerList is used by classes that provide large numbers of events to more efficiently handle memory by only allocating space for the event backing field when it is needed rather than when the event is declared. All events for the main form are therefore stored there.

    I would expect the child form was monitoring when its parent may close (this is a common use-case) and it didn’t unsubscribe from the FormClosing or FormClosed event when it received that event. However, that’s just a guess. To confirm, look at your child form implementation and find all cases where it subscribes to events from the parent form, then make sure there is a corresponding unsubscription from those events.

    Update
    The menu handler you found that was not removed could well be the root of the issue you see. Try adding the remove call and see if that addresses the leak.

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

Sidebar

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.