Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
.Dispose
Message
From
21/03/2006 12:36:47
 
 
To
21/03/2006 11:27:07
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, United States
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Miscellaneous
Thread ID:
01106252
Message ID:
01106287
Views:
21
Some dotnet objects run in unmanaged code. There is no garbage collection in unmanaged code. So you need to explicitly call "dispose" on these objects when you are done with them, otherwise you will suffer memory leaks.

Two examples I know of are ADO.net and GDI graphics. That's one of the reasons why in C#, the prefered method of creating a connection and the subsequent steps of a dataset, dataadapter, etc. is within a using block.

Using....calls dispose when it's all done.


>I haven't received any formal training with .NET. Since I am mostly self-taught, there are quite a few things I do just because I read somewhere I need to do them, and not understanding why.
>
>One of these is the .Dispose routine. Do I need to be calling this, and if so for what? When I declare certain things like datasets, forms, and other objects I just check to see if I can dispose of them, and if I can then I do.
>
>I understand the concept of Garbage Collection for the most part, so shouldn't that be enough?
>
>I would appreciate any advice!
>
>Thanks,
>Mike

(On an infant's shirt): Already smarter than Bush
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform