Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
.Dispose
Message
De
21/03/2006 12:36:47
 
 
À
21/03/2006 11:27:07
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Divers
Thread ID:
01106252
Message ID:
01106287
Vues:
20
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform