I am using Visual Basic .Net 2005 professional.
From what I understand, I should be disposing of any object that is an unmanaged resource. I understand the best way to tell if a resource is unmanaged is if it has a Dispose method. ie: If I type a dot after my object, intellisense shows .Dispose() as one of the options. If it does, it's an unmanaged resource. Is that correct?
In that case, pretty much every control is an unmanaged resource: buttons, forms, panels, etc.
In the application I am working on I use an MDIparent container form, which contains MDI children forms, which themselves contain Panels, Menus, Groupboxes, etc, which in turn contain Buttons, Textboxes, Labels, Dropdowns, etc.
Do I have to dispose of each button, textbox, label and dropdown within a panel before disposing of the panel?
Do I have to dispose of each panel, menu, and groupbox before disposing of the MDI child form?
...Or can I just call the Dispose() method of the MDIchild form and the GarbageCollecto r will take care of all the controls and resources within the form?
Watching the "mem usage" in Windows Task Manager seems to be an unreliable way to detect if I have a memory leak. The numbers just keep climbing and falling (mostly climbing) erratically and without any activity performed on the application. Is there some (relatively) easy way to detect leaks?
From what I understand, I should be disposing of any object that is an unmanaged resource. I understand the best way to tell if a resource is unmanaged is if it has a Dispose method. ie: If I type a dot after my object, intellisense shows .Dispose() as one of the options. If it does, it's an unmanaged resource. Is that correct?
In that case, pretty much every control is an unmanaged resource: buttons, forms, panels, etc.
In the application I am working on I use an MDIparent container form, which contains MDI children forms, which themselves contain Panels, Menus, Groupboxes, etc, which in turn contain Buttons, Textboxes, Labels, Dropdowns, etc.
Do I have to dispose of each button, textbox, label and dropdown within a panel before disposing of the panel?
Do I have to dispose of each panel, menu, and groupbox before disposing of the MDI child form?
...Or can I just call the Dispose() method of the MDIchild form and the GarbageCollecto r will take care of all the controls and resources within the form?
Watching the "mem usage" in Windows Task Manager seems to be an unreliable way to detect if I have a memory leak. The numbers just keep climbing and falling (mostly climbing) erratically and without any activity performed on the application. Is there some (relatively) easy way to detect leaks?
Comment