473,569 Members | 2,813 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 7169
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.C ontrols.Clear()

Nirosh.

"james" <no****@hyperco n.net> wrote in message
news:#Z******** ******@tk2msftn gp13.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*****@textce ntric.lk> wrote in message
news:#b******** ******@TK2MSFTN GP09.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.C ontrols.Clear()

Nirosh.

"james" <no****@hyperco n.net> wrote in message
news:#Z******** ******@tk2msftn gp13.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
5271
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 4-month old C#/MC++ .NET project project. I'd like to thank in advance anyone who takes the time to read and/or respond to this message. At a couple...
24
7641
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 Dispose-Method and call the GC nothing happend!!! my Disposemethod has never been called!! so the GC dont call my Dispose-Method although I...
4
2024
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 the heap and release the memory when it's deleted from the hash table so that GC recollection does not need to run that frequently. I read up...
2
8295
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 showing one transparent form (form3) when ever user preseed left mouse button. 3) The form3 has one transparent user control (usercontrol2) that paints...
1
3904
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 the same thing as the deconstructor in the following example (~YourClassNameHere()). What would cause the deconstructor to fire off over the...
3
9955
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 SaveXLReport method completes successfully, calls myXLClass.Dispose, and returns control to the user form at a base state. At this point, there is still an...
0
2425
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 (http://support.microsoft.com/kb/810852), but then I realized that the hotfix mentioned was in .Net v1.1, which I am using. I took the sample from that...
4
2459
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 example, it's less visible because controls don't execute any code... Is someone has an idea of how I could solve this problem and also improve the method...
71
10701
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 is that automatic? Thanks
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7618
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8138
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7679
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5223
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1228
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
946
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.