<performanceCounters> 元素<performanceCounters> Element

指定由性能计数器共享的全局内存的大小。Specifies the size of the global memory shared by performance counters.

<configuration>
  <system.diagnostics>
    <performanceCounters>

语法Syntax

<performanceCounters filemappingsize="524288" />

特性和元素Attributes and Elements

下列各节描述了特性、子元素和父元素。The following sections describe attributes, child elements, and parent elements.

特性Attributes

属性Attribute 说明Description
filemappingsizefilemappingsize 必需的特性。Required attribute.

指定由性能计数器共享的全局内存的大小(以字节为单位)。Specifies the size, in bytes, of the global memory shared by performance counters. 默认值为 524288。The default is 524288.

子元素Child Elements

无。None.

父元素Parent Elements

元素Element 描述Description
Configuration 公共语言运行时和 .NET Framework 应用程序所使用的每个配置文件中的根元素。The root element in every configuration file used by the common language runtime and .NET Framework applications.
system.diagnostics 为 ASP.NET 配置节指定根元素。Specifies the root element for the ASP.NET configuration section.

注解Remarks

性能计数器使用内存映射文件或共享内存来发布性能数据。Performance counters use a memory mapped file, or shared memory, to publish performance data. 共享内存的大小决定了可同时使用的实例数。The size of the shared memory determines how many instances can be used at once. 共有两种类型的共享内存:全局共享内存和单独的共享内存。There are two types of shared memory: global shared memory and separate shared memory. 与 .NET Framework 版本1.0 或1.1 一起安装的所有性能计数器类别均使用全局共享内存。The global shared memory is used by all performance counter categories installed with the .NET Framework versions 1.0 or 1.1. 随 .NET Framework 版本2.0 一起安装的性能计数器类别使用单独的共享内存,其中每个性能计数器类别都有自己的内存。Performance counter categories installed with the .NET Framework version 2.0 use separate shared memory, with each performance counter category having its own memory.

全局共享内存的大小只能与配置文件一起设置。The size of global shared memory can be set only with a configuration file. 默认大小为 524288 byes,最大大小为33554432个字节,最小大小为32768个字节。The default size is 524,288 byes, the maximum size is 33,554,432 bytes, and the minimum size is 32,768 bytes. 由于全局共享内存由所有进程和类别共享,因此第一个创建者指定大小。Since the global shared memory is shared by all processes and categories, the first creator specifies the size. 如果在应用程序配置文件中定义大小,则仅当应用程序是导致性能计数器执行的第一个应用程序时,才使用该大小。If you define the size in your application configuration file, that size is only used if your application is the first application that causes the performance counters to execute. 因此,指定值的正确位置 filemappingsize 是 machine.config 文件。Therefore the correct location to specify the filemappingsize value is the Machine.config file. 全局共享内存中的内存不能由单独的性能计数器释放,因此,如果创建了大量具有不同名称的性能计数器实例,则最终的全局共享内存会耗尽。Memory in the global shared memory cannot be released by individual performance counters, so eventually global shared memory is exhausted if a large number of performance counter instances with different names are created.

对于单独的共享内存的大小,先引用注册表项 HKEY_LOCAL_MACHINE \SYSTEM\CurrentControlSet\Services \Performance 中的 DWORD FileMappingSize 值 \ <category name> ,然后引用在配置文件中为全局共享内存指定的值。For the size of separate shared memory, the DWORD FileMappingSize value in the registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\<category name> \Performance is referenced first, followed by the value specified for the global shared memory in the configuration file. 如果 FileMappingSize 值不存在,则会在配置文件中将单独的共享内存大小设置为第四(1/4)个全局设置。If the FileMappingSize value does not exist, then the separate shared memory size is set to one fourth (1/4) the global setting in the configuration file.

另请参阅See also