- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我正在尝试访问位于 ".NET CLR Memory category" 中的性能计数器通过 C# 使用 PerformanceCounter 类。但是,无法使用我期望的正确类别/计数器名称来实例化类别
new PerformanceCounter(".NET CLR Memory", "# bytes in all heaps", Process.GetCurrentProcess().ProcessName);
我尝试使用以下代码循环遍历类别和计数器
string[] categories = PerformanceCounterCategory.GetCategories().Select(c => c.CategoryName).OrderBy(s => s).ToArray();
string toInspect = string.Join(",\r\n", categories);
System.Text.StringBuilder interestingToInspect = new System.Text.StringBuilder();
string[] interestingCategories = categories.Where(s => s.StartsWith(".NET") || s.Contains("Memory")).ToArray();
foreach (string interestingCategory in interestingCategories)
{
PerformanceCounterCategory cat = new PerformanceCounterCategory(interestingCategory);
foreach (PerformanceCounter counter in cat.GetCounters())
{
interestingToInspect.AppendLine(interestingCategory + ":" + counter.CounterName);
}
}
toInspect = interestingToInspect.ToString();
但找不到任何似乎匹配的内容。是否无法从 CLR 中观察这些值,还是我做错了什么。
如果重要的话,环境是在 64 位 Windows 7 机器上运行的 .NET 4.0。
最佳答案
您需要以管理员身份运行程序才能访问 .NET CLR 内存类别。
使用 powershell 试试这个简单的测试:
以管理员身份运行时
[Diagnostics.PerformanceCounterCategory]::Exists(".NET CLR Memory")
True
在没有管理权限的情况下运行:
[Diagnostics.PerformanceCounterCategory]::Exists(".NET CLR Memory")
False
关于C#:访问 ".NET CLR Memory category"的 PerformanceCounters,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4705698/
以下段落使我感到困惑: 来自文章:Acquiring high-resolution time stamps When you need time stamps with a resolution o
我有六台机器要使用 perfmon 进行监控。我想在所有六个计数器上使用相同的一组计数器。有没有办法设置模板,以便我可以一次指定这些计数器,然后根据此模板设置其他数据收集器?还是我真的必须手动设置每个
我正在尝试设置我的 Azure Web 应用程序以包含第三方软件的使用,这似乎需要访问 PerformanceCounters。在本地,这工作正常,但是当我在 Azure 中运行它时,出现以下错误:
我用perf脚本命令查看perf.data文件的结果,但我不是很明白每一列的含义。例如,如果我有以下结果: perf 3198 [000] 13156.201238: bus-cycles: ff
我想知道是否有用于精确时间测量(如函数的执行时间)的“.net 集成”解决方案?目前我正在使用 Kernel32 的 PerformanceCounters。 [DllImport("Kern
我尝试使用 PerformanceCounter 来监控域环境中的远程服务器信息,例如: var counter = new PerformanceCounter("PhysicalDisk", "D
我正在使用 System.Data PerfomanceCounter 类,并且我找到了一些关于如何检索磁盘空间或 CPU 使用率的非常具体的示例。 但是我找不到关于以下可能值的文档: Perfoma
我知道使用 Perfmon.msc 您可以创建自定义性能计数器,并且通过使用计数器日志,您可以将计数器值写入文本文件。 我也明白我也可以通过使用 System.Diagnostics.Performa
我正在研究电荷平衡系统,因此我需要知道每台机器的电荷。 PerformanceCounter 似乎是可行的方法,但创建第一个需要 38 到 60 秒。然而,每个后续的新 Counter 或“NextV
我想访问在具有不同本地化的系统上运行的应用程序中的“处理器时间 %”计数器。 为此,我想通过其索引访问计数器,该索引保证是唯一的(请参阅 https://support.microsoft.com/e
我在一台服务器上工作,它从 PerformanceCounters 读取“% CPU”和“可用内存”。它在我的开发机器上运行良好。但是在实际的服务器上,读取这两个 PerformanceCounter
我有一个 Windows 服务,它跨多个线程运行框架的实现。每个正在运行的实例都有一些我需要跟踪的共同点,例如,处理的项目数、上次处理项目的时间等。在此基础监控数据之上,我想在框架允许实现动态添加自己
我正在使用 C# 的“PerformanceCounter”类来计算“内存”类别下的以下 2 个计数器“可用字节数”和“使用中的 promise 字节数百分比”。 Perfor
我不知道为什么,但是很多电脑在执行以下操作时挂起: void Init() { net1 = new List(); net2 = new List(); foreach (s
我正在制作一个程序,我需要从性能计数器中获取一些值。 目前一切正常。但是,当我尝试获取特定 IIS 站点的“Requests/Sec”计数器时,我没有获得任何值,比如它根本没有更新。但是,如果我在我的
我在使用 PerformanceCounter 时遇到问题,我想获取 CPU 温度,但我只找到了这个: PerformanceCounter tempCount = new PerformanceCo
我在我的应用程序中使用 QueryPerformanceCounter() 函数来测量时间。此功能还用于提供我的应用程序生命周期的时间线。最近我注意到其他时间函数的时间有偏差。最后,我写了一个小测试来
伙计们,我有以下代码: using System.Diagnostics; private PerformanceCounter diskRead = new PerformanceCounter()
我正在尝试了解如何收集计算机上每个处理器的当前使用百分比。如果我使用“System.Environment.ProcessorCount;”我可以获得计算机上的处理器数量,它当前返回“2”。我不知道自
我正在尝试手动将一些 PerformanceCounters 发送到 ApplicationInsights。 我尝试使用以下正文直接发布到 https://dc.services.visualstu
我是一名优秀的程序员,十分优秀!