Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
150
(UltraToolTipInfo dispose
posted

Dear All,

I have a question about the UltraToolTipInfo dispose. If I used the following codes, sometimes I will get application crash.

using(UltraToolTipInfo toolTipInfo = new UltraToolTipInfo("Enter some text here.", ToolTipImage.Info, "This is textBox1", DefaultableBoolean.True))

{

this.ultraToolTipManager1.SetUltraToolTip(this.textBox1, toolTipInfo);
}

The object was disposed at the end of the using but depending on when the Garbage Collector actually deleted the memory, a random crash would occur when trying to access this tooltip object again when attempting to display the tooltip. I searched that the dispose method is empty. So I am not very sure it's the right way to use this.

Right now I use the Coverity to statically analyze the codes. If toolTipInfo is not disposed, there will be a message that "Resource leak (RESOURCE_LEAK)Returning without disposing "tipInfo"". That's why I want to do it like this.

From your help website, it does not use "using" to wrap it. I wanna know

1. if i do not dispose toolTipInfo and ultraToolTipManager1, is there any risk of memory leak?

2. Do I have to declare a UltraToolTipInfo variable for whole class and dispose it in the Class's dispose method?

3. Do I have to dispose ultraToolTipManager1?

4. Is there any way to solve the problem from Coverity?
http://help.infragistics.com/Help/Doc/WinForms/2012.2/CLR4.0/html/Infragistics4.Win.v12.2~Infragistics.Win.UltraWinToolTip.UltraToolTipInfo.html

Thank you very much.

Thanks & Regards,

Li

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    This code doesn't make sense. Why would you dispose the tooltip like this? You are creating a new ToolTipInfo and calling SetToolTipInfo to assign that ToolTopInfo object to a control. But the object is then immediately disposed. So if the control or the ToolTipManager attempts to access that TooTipInfo, it is disposed and, of course, it will blow up.

    The best easiest thing to do is to use GetToolTipInfo and then modify the properties of the ToolTipInfo that it returns. This way, the ToolTipInfo is created by the ToolTipManager and the ToolTipManager is responsible for disposing it.

    If you create the ToolTipInfo, then you have to keep a reference to it and dispose it yourself. But you can only do that once it's not being used any more - you can't do it immediately after creating it.

    As for disposing the ToolTipManager, the answer is yes - it should be disposed. If you place it on a form at design-time, you don't have to worry about it, though, because the form will dispose of the component when the form is disposed.

Children