Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
System.OutOfMemoryException and IDisposable
Message
De
19/12/2011 03:43:34
 
 
À
13/12/2011 04:06:58
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
VB 8.0
OS:
Windows 7
Network:
Windows 2008 Server
Database:
MySQL
Divers
Thread ID:
01530931
Message ID:
01531308
Vues:
86
>Hello All,
>
>Every day the memory consumed getting bigger and bigger and in someday System.OutOfMemoryException thrown..
>Does it because of the class has not been disposed ?
>
>I am trying to implement IDisposable .. and I would appreciate if someone can give me suggestion or comment regarding on it..
>
>please advise..
>
>TIA
>Winanjaya
>
>Code in Cls1
>
>
>object[] para = new object[] { para1, para2, para3 };
>using (Cls1 cls1 = new Cls1())
>{
>    cls1.MainProc(para);
>}
>
>
>Code class Cls1 : IDisposable
>
>{
>    IntPtr _maxworkset = curProc.MaxWorkingSet;
>    public void MainProc(object para)
>    { 
>      // DO SOMETHING HERE!
>     }
>
>    public void Dispose() 
>    {    
>        GC.SuppressFinalize(this);                  
>        curProc.MaxWorkingSet = _maxworkset;
>    }
>}
>
A robust implementation 0f IDisposable is a bit more intricate. There's an example here: http://msdn.microsoft.com/en-us/library/aa720161(v=vs.71).aspx (which, by chance, actually has an IntPtr as unmanaged content)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform