473,407 Members | 2,306 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

UserControl's and Dispose/GC.Collect question

If I have a user control with some control on it like
a TextBox's and buttons does calling the default Dispose
on my user control cause those inner controls to also
be disposed ? Or must I do my own disposing for
all those too??

thanks,

JIM
Nov 15 '05 #1
2 7161
Hi,

It is not clear how you call the dispose method here

if you need to dispose a specific control such as a button then you can call
the button.Dispose() method or else if you need the whole control colletion
to be clear then you can call the MyUserControl.Controls.Clear()

Nirosh.

"james" <no****@hypercon.net> wrote in message
news:#Z**************@tk2msftngp13.phx.gbl...
If I have a user control with some control on it like
a TextBox's and buttons does calling the default Dispose
on my user control cause those inner controls to also
be disposed ? Or must I do my own disposing for
all those too??

thanks,

JIM

Nov 15 '05 #2
Chanpika,

What I am saying is this, I have a Custom User Control,
that has many inner controls on it. When I want it to
go away entirely and free all its memory, my containing
Form does this,

SomeUserControl.Dispose();
SomeUserControl = null;
GC.Collect();

But, what I am finding is that no memory is being freed.
I know this because I have many of these controls, that
I create, display and destroy, and as I create them I can
see memory going up, but as I destroy them memory
does not go down. My application is gobbling up
over 250MB by itself, when I know for a fact that it only
requires about 60MB initially, but as time goes on, it keeps
growing until eventually the OS just kills it because it has
grabbed too much menory. So, I am guessing that each
UserControl is not releasing its inner controls. I thought
that since those were in the this.Controls() IList that they
would be auto handled by the base class's destroy.
So that was my question. Are inner controls auto freed
or not ???

thanks,

JIM

"Champika Nirosh" <cn*****@textcentric.lk> wrote in message
news:#b**************@TK2MSFTNGP09.phx.gbl...
Hi,

It is not clear how you call the dispose method here

if you need to dispose a specific control such as a button then you can call the button.Dispose() method or else if you need the whole control colletion to be clear then you can call the MyUserControl.Controls.Clear()

Nirosh.

"james" <no****@hypercon.net> wrote in message
news:#Z**************@tk2msftngp13.phx.gbl...
If I have a user control with some control on it like
a TextBox's and buttons does calling the default Dispose
on my user control cause those inner controls to also
be disposed ? Or must I do my own disposing for
all those too??

thanks,

JIM


Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Ken Durden | last post by:
I am in search of a comprehensive methodology of using these two object cleanup approaches to get rid of a number of bugs, unpleasantries, and cleanup-ordering issues we currently have in our...
24
by: Jazper | last post by:
hi i have this problem. i made a class deverted by CRootItem with implementation of IDisposable-Interface. i made a test-funktion to test my Dispose-Method.... but when set a breakpoint in my...
4
by: xyu | last post by:
Hello, First I would like to thank anyone who helps me, much appreciated. I'm a c++ programmer just started using c#. I'm writing some big hash table so I want to actively take my object off...
2
by: Jaikumar | last post by:
Hi, 1) I have created one windows application, In the main form ( form1) i have added one usercontrol (usercontrol1), In that user control i am drawing one image. 2) In the UserControl1 i am...
1
by: Cider123 | last post by:
Ran across some code on the net that incorporates "dispose" 2 different ways.. I understand a calling routine could use the .Dispose on your class, but I was under the impression "Dispose()" was...
3
by: Vagabond Software | last post by:
Scenario: The end-user selects File-Save from my applications (WinForm) menu, specifies a filename, and waits waits for my app to write the contents of a dataset to an Excel workbook. The...
0
by: Gary Shell | last post by:
I am experiencing some strange behavior between a UserControl's validating event and a treeview control. Initially, I thought it was related to an issue in the Knowledgebase article 810852...
4
by: Martin | last post by:
Hi everyone ! For those who haven't read my previous post, I have a problem with a UserControl. When I try to display it on a form, controls seem to appear one after one. In the following...
71
by: active | last post by:
In the main program I check to see if a certain form has been disposed. Does it make sense in that form's FormClosed event to do: Me.Dispose to make sure it is disposed the next time I check. Or...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.