Unload the appdomains and check the working set : Environment : Development C# Examples


C# Examples » Development » Environment »

 

Unload the appdomains and check the working set









    
using  System;
using  System.Collections;
using  System.Collections.Generic;
using  System.Diagnostics;
using  System.Globalization;
using  System.IO;
using  System.Reflection;
using  System.Security;
using  System.Security.Permissions;
using  System.Security.Policy;

public  class  MainClass
{
        public  static  void  Main()
        {
                List<AppDomain>  ads  =  new  List<AppDomain>();
                for  (int  i  =  0;  i  <  10;  i++)
                {
                        AppDomain  ad  =  AppDomain.CreateDomain(i.ToString());
                        ad.DoCallBack(delegate  {  Type  t  =  typeof(Uri);  });
                        ads.Add(ad);
                }
                Console.WriteLine("After  loading  System.dll  into  10  AppDomains:  {0}",  Environment.WorkingSet);

                
                foreach  (AppDomain  ad  in  ads)
                        AppDomain.Unload(ad);
                Console.WriteLine("After  unloading  the  AppDomains:  {0}",  Environment.WorkingSet);
        }

}
    
   
  
   



Output

After loading System.dll into 10 AppDomains: 8544256
After unloading the AppDomains: 8519680


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Development
» Environment