Unload the appdomains and check the working set : Environment « Development « C# / CSharp Tutorial






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);
    }

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








14.2.Environment
14.2.1.Accessing Environment Settings: Environment.StackTrace
14.2.2.Accessing Environment Settings:
14.2.3.Accessing Environment Settings: Get OS version
14.2.4.Get the drives on this box
14.2.5.Accessing Environment Settings: Environment Variables
14.2.6.Accessing Environment Settings: Logical Drives
14.2.7.Access the command-line arguments directly through Environment.CommandLine
14.2.8.Environment.NewLine
14.2.9.Enumerate all special folders and display them
14.2.10.Retrieve a named environment variable
14.2.11.Expand Environment Variables
14.2.12.Retrieve all environment variables targeted at the process
14.2.13.Is AppDomain Finalizing For Unload(), Environment.HasShutdownStarted
14.2.14.WorkingSet change after loading the DLL
14.2.15.WorkingSet change After loading System.dll into 10 AppDomains
14.2.16.Unload the appdomains and check the working set
14.2.17.Accessing Environment Settings: Environment.CurrentDirectory and SystemDirectory
14.2.18.Accessing Environment Settings: Environment.MachineName and Environment.Version
14.2.19.Use GetFolderPath method to return and display the path associated with the folder parameter.
14.2.20.Sample for the Environment.GetEnvironmentVariables method
14.2.21.Start Internet Explorer and display the contents of the Favorites folder