可以通过将AppDomain.MonitoringIsEnabled 设置为true开启监控域的资源

之后可以通过访问以下属性获取域的资源消耗

  1. MonitoringSurvivedMemorySize

      2. MonitoringSurvivedProcessMemorySize

      3. MonitoringTotalAllocatedMemorySize 

      4. MonitoringTotalProcessorTime

不过这里有些非常恶心的地方

  1. 开启监控是全局的..你不能只能只监控某个域

  2. 开了就关不掉了....如果在将MonitoringIsEnabled 设置为ture以后 再尝试将它设置为false,将抛出一个ArgumentException

  这个设计真是糟糕啊.....一个属性只能给他赋值true....

  3. 开启这个监控会造成性能损失(经过测量  new object 的操作大概需要多消耗50%的cpu时间)

相关文章:

  • 2021-12-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-27
  • 2021-05-18
猜你喜欢
  • 2021-06-16
  • 2022-02-13
  • 2021-10-20
  • 2022-12-23
  • 2021-07-20
  • 2022-12-23
相关资源
相似解决方案