This article is a mirror article of machine translation, please click here to jump to the original article.

View: 26378|Reply: 0

[Source] Monitor AppDomains

[Copy link]
Posted on 5/30/2018 10:33:32 AM | | | |
The host application monitors the resources consumed by the AppDomain. Some hosts use this information to determine whether the memory or CPU consumption of an AppDomain exceeds the appropriate level, and force an AppDomain to be uninstalled.

You can also use monitoring to compare the resource consumption of different algorithms and determine which algorithm uses fewer resources. Since AppDomain monitoring inherently incurs overhead, the host must set the AppDomain's static property MonitoringEnabled to true to show open monitoring.Monitoring cannot be turned off once turned on; If you try to set MonitoringEnabled to false, an ArgumentException is thrown



Once the monitoring is turned on, your code can query the following four read-only properties provided by the AppDomain class.

  • MonitoringSurvivedProcessMemorySize This Int64 static property returns the number of bytes used by all AppDomains controlled by the current CLR instance. This number is only guaranteed to be accurate when the last garbage collection was made.
  • The MonitoringTotalAllocatedMemorySize property of this Int64 instance returns the number of bytes allocated to a specific AppDomain. This number is only guaranteed to be accurate when the last garbage collection was made.
  • The MonitoringSurvivedMemorySize property of this Int64 instance returns the number of bytes currently in use by a particular AppDomain. This number is only guaranteed to be accurate when the last garbage collection was made.
  • MonitoringTotalProcessorTime is a TimeSpan instance property that returns the CPU usage of a specific AppDomain.

The following demonstrates how to use these three properties to check for changes in an AppDomain between two points in time:



The following demonstrates how to use the AppDomainMonitorDelta class







Previous:[Reprint]. net/c# MessageBox pop-up pop-up countdown is automatically closed
Next:Newtonsoft.Json ignores the DataContract feature
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com