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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:32:53+00:00 2026-05-27T01:32:53+00:00

I’ve been tracking down a memory leak and I’ve narrowed it down to a

  • 0

I’ve been tracking down a memory leak and I’ve narrowed it down to a ToolTip that is allocated in a UserControl-derived class.

The ToolTip is allocated in the allocated in the control’s constructor and initialized in the Load event like this:

public class CommonProfile : System.Windows.Forms.UserControl
{
    private ToolTip toolTip1;

    ...

    public CommonProfile()
    {
        InitializeComponent();

        // Create the ToolTip and associate with the Form container.
        toolTip1 = new ToolTip(this.components);
    }

    private void CommonProfile_Load(object sender, System.EventArgs e)
    {
        // Set up the delays for the ToolTip.
        toolTip1.AutoPopDelay = 5000;
        toolTip1.InitialDelay = 1000;
        toolTip1.ReshowDelay = 500;
        // Force the ToolTip text to be displayed whether or not the form is active.
        toolTip1.ShowAlways = true;

        // Set up the ToolTip text
        toolTip1.SetToolTip(this.btnDeleteEntry, "Delete this Profile");
        toolTip1.SetToolTip(this.lblProfileType, "Edit this Profile");
        toolTip1.SetToolTip(this.lblProfileData, "Edit this Profile");
        toolTip1.SetToolTip(this.picFlagForUpdate, "Toggle Flag for Update");
    }    
}

The control’s parent has a lifetime that exceeds the control’s lifetime. This control is created on the fly and added to a panel control and then subsequently removed from the panel control.

I found that the control’s Dispose member was not getting called, apparently because references to the ToolTip remain.

I added a Shutdown method like this:

public void Shutdown()
{
    toolTip1.RemoveAll();
}

Calling the Shutdown method eliminates the leak and Dispose is eventually called.

Unfortunately, this solution requires that whoever uses the control remembers to call the Shutdown method when they are finished with it.

I’d like to know if there is some way that I can automate this so that it happens without the need to call the Shutdown method explicitly.

  • 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-27T01:32:53+00:00Added an answer on May 27, 2026 at 1:32 am

    You aren’t showing the code for how you are disposing your UserControl from your Panel.

    Just calling:

    panel1.Controls.Remove(userControl1);
    

    isn’t going to dispose the UserControl.

    You need to specifically call:

    userControl1.Dispose();
    

    which will also automatically remove it from the Panel. In your UserControl, if you need to do your own clean up, try subscribing to it’s own Dispose event:

    private ToolTip toolTip1;
    
    public UserControl1() {
      InitializeComponent();
      // tooltip initialization
      this.Disposed += UserControl1_Disposed;
    }
    
    private void UserControl1_Disposed(object sender, EventArgs e) {
      if (toolTip1 != null)
        toolTip1.Dispose();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am doing a simple coin flipping experiment for class that involves flipping a
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post

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.