Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to release object stored in property?
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 3.0
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01397173
Message ID:
01397184
Vues:
39
>Hi,
>I initialize object to private vairable via
>
>public class MyBase
>{
>private MyClass _myClass = new MyClass();
>}
>
>I found that it caused memory leak as it is not released. May I know how should I release it once myBase is released?

As long as there are no longer any other references to that class the garbage collector will clean it up. However, garbage collection doesn't occur immediately. It can take quite a while for it to clean up. Since .NET uses a generational garbage collector the longer MyBase lives the longer it can take for the GC to clean up other references held. It can look like a memory leak when it really isn't.
-Paul

RCS Solutions, Inc.
Blog
Twitter
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform