Performance Counters in the .NET Compact FrameworkÂ
The .NET Compact Framework does not support PerformanceCounter objects because they do not pertain to Windows CE and the .NET Compact Framework. However, the .NET Compact Framework contains a set of predefined performance counters for analyzing the types of load your application has on the .NET Compact Framework. The counters are not extensible.
You can generate a file on your device that contains performance statistics about your application. For a step-by-step procedure, see How to: Generate Performance Statistics.
The performance counters are useful for understanding the impact of garbage collection and just-in-time compilation on application performance. From these statistics you can determine where optimizations should occur.
The statistics file lists the performance counters with the following columns.
Column | Description |
---|---|
Total |
Summation of occurrences. |
Last Datum |
The last piece of information. |
N |
The number of occurrences. |
Mean |
The intermediate between other values. |
Min |
The minimum value. |
Max |
The maximum value. |
.NET Compact Framework Counters
The performance counters are organized in the following categories.
Loader |
JIT compilation |
Generics |
Exceptions |
Locks and threads |
Interop |
Garbage collection |
Networking |
Memory |
Windows Forms |
Loader Counters
The following counters pertain to the portion of the common language runtime (CLR) that is responsible for resolving and loading components that are referenced by your application, such as assemblies and classes.
Name and short name | Description | Counter type |
---|---|---|
Total Program Run Time (ms) RunTime |
The elapsed time, in milliseconds, from CLR invocation. |
Calculated |
App Domains Created napplication domains |
The number of application domains created in the application's process. |
Simple |
App Domains Unloaded napplication domainsUnloaded |
The number of application domains that have been unloaded during the run time of the application. |
Simple |
Assemblies Loaded nAssembliesloaded |
The number of assemblies that have been loaded across all application domains for the application. |
Simple |
Classes Loaded nClassesloaded |
The number of classes that have been loaded across all application domains during the run time of the application. |
Simple |
Methods Loaded nMethodsloaded |
The total count of methods loaded across all application domains during the run time of the application. |
Simple |
Generics Counters
The generics counters are loader counters that are specific to the generics feature of the .NET Compact Framework version 2. The CLR uses generics internally. Consequently, you might see values in these counters even if your application does not use generics explicitly.
Name and short name | Description | Counter type |
---|---|---|
Closed Types Loaded nInstGenericTypesLoaded |
The count of unique generic types that have been loaded across all application domains. A closed type is a generic class that has been bound with a specific data type. For example, an instance of |
Simple |
Closed Types Loaded per Definition nMaxClosedTypes |
The maximum number of unique generic types created for a given definition across all application domains. For example, if an application instantiates A large number (several hundred or more) in the Max column can indicate working-set pressure in terms of JIT-compiled code and CLR data structures. |
StaticOnly |
Open Types Loaded nOpenTypesLoaded |
The count of open generic types created across all application domains. An open type is a generic class that has been loaded, but has not been bound with a specific data type. Open types are typically created only in reflection scenarios. For example, loading an instance of |
Simple |
Closed Methods Loaded nInstGenericMethodsLoaded |
The count of unique generic methods that have been loaded across all application domains. A closed method is a generic method that has been bound with a specific data type. The type that contains the method may or may not be a generic type. For example, an instance of |
Simple |
Closed Methods Loaded per Definition nMaxClosedMethods |
The maximum number of unique generic methods created for a given definition across all application domains. This counter is very similar to the Closed Types Loaded per Definition counter. Using the following instances of As with the Closed Types Loaded per Definition counter, a large number (several hundred or more) in the Max column can indicate working-set pressure in terms of JIT-compiled code and CLR data structures. |
StaticOnly |
Open Methods Loaded nOpenMethodsLoaded |
The count of open generic methods created across all application domains. Open methods are typically created only in reflection scenarios. An open method is a generic method that has been loaded, but not bound to a specific type. The .NET Compact Framework runtime uses reflection internally and can be the source of the open methods. |
Simple |
Locks and Threads Counters
The following counters pertain to threading, locks, timers, and thread pools. These counters can help identify threading-related performance issues by providing data on thread, timer, and lock usage during the run time of your application.
Name and short name | Description | Counter type |
---|---|---|
Threads in Thread Pool nThreads |
The number of threads currently in the thread pool. This counter counts the threads that are started by using the QueueUserWorkItem method. This counter does not include threads that are started by using the Start method. |
MinMax |
Pending Timers nPendingTimers |
The number of timers currently queued. |
MinMax |
Scheduled Timers nTimersStarted |
The number of timers that are currently running or scheduled to run. |
Simple |
Timers Delayed by Thread Pool Limit nTimersDelayed |
The count of timers that have been delayed by the thread pool limit. |
Simple |
Work Items Queued nWorkItemsQueued |
The count of work items queued to the thread pool. |
Simple |
Uncontested Monitor.Enter Calls nUncontestedMonitor |
Count of calls made to the Enter method that were not contested. |
Simple |
Contested Monitor.Enter Calls nContestedMonitor |
Count of calls made to Enter that were contested. In multi-threaded applications, if Thread1 is holding a lock and Thread2 needs to access code that is guarded by the lock, the Contested Monitor.Enter Calls counter is incremented. |
Simple |
Garbage Collection Counters
The following counters pertain to garbage collection operations.
Name and short name | Description | Counter type |
---|---|---|
Peak Bytes Allocated (native + managed) cbPeakMemUsage |
The maximum number of bytes in use by the CLR, including both native and managed memory. |
Calculated |
Managed Objects Allocated nObjectsAllocated |
The count of objects allocated by the garbage collector. |
Simple |
Unused Managed Objects Allocated nObjectsAllocatedNotUsed |
The count of objects allocated that were never used. |
Simple |
Managed Bytes Allocated cbAllocated |
The count of bytes allocated by the garbage collector. |
Complex |
Unused Managed Bytes Allocated cbAllocatedNotUsed |
The count of bytes allocated that were never used. |
Complex |
Managed String Objects Allocated nStrings |
The number of managed string objects allocated by the garbage collector. |
Simple |
Bytes of String Objects Allocated nStringBytes |
The count of bytes of string objects allocated by the garbage collector. |
Simple |
Garbage Collections (GC) nGC |
The number of times the garbage collector has run. |
Simple |
Bytes Collected by GC cbGarbage |
The count of bytes collected by the garbage collector. |
Complex |
Managed Bytes in Use After GC cbLive |
The number of bytes allocated to live objects after the last garbage collection. |
MinMax |
Total Bytes in Use After GC cbWorkingSetMem |
The number of bytes of memory, native and managed, in use after the last garbage collection. |
MinMax |
GC Compactions nCompactions |
The number of times the garbage collector has compacted the heap. |
Simple |
Code Pitchings nPitches |
The number of times the garbage collector has discarded JIT-compiled code. |
Simple |
Calls to GC.Collect nInduced |
The number of times the application has called the Collect method. |
Simple |
GC Latency Time (ms) msLatency |
The total time, in milliseconds, that the garbage collector has taken to collect objects and compact the heap. The latency time of the garbage collector includes the time to collect managed objects that are no longer in scope and the compaction time, if necessary, of the GC Heap. |
Complex |
Pinned Objects nPinned |
The count of pinned objects encountered while performing a garbage collection. Pinned objects are objects whose locations in memory cannot change. For example, a memory buffer that is being used to communicate between managed and unmanaged code is a pinned object. Pinned objects cannot be moved by the garbage collector during heap compaction. |
Simple |
Objects Moved by Compactor nObjMoved |
The count of objects moved by the garbage collector during a compaction. |
Simple |
Objects Not Moved by Compactor nObjNotMoved |
The count of the objects that were not moved by the garbage collector during a compaction. Objects might not be moved for a number of reasons. Some objects cannot be moved, but these objects are rare. Other objects are not moved because they are in a portion of the heap that does not need to be compacted. |
Simple |
Objects Finalized nFinalizersRun |
The count of objects for which a finalizer has been run. |
Simple |
Boxed Value Types nBoxes |
The number of value types that have been boxed. |
Simple |
Memory Counters
The following counters pertain to the memory heaps managed by the garbage collector.
Name and short name | Description | Counter type |
---|---|---|
Process Heap HeapDefault |
The number of bytes currently in use by the CLR's default heap. The Process Heap contains memory allocated by the CLR that does not fit into the other heaps listed in this table. |
MinMax |
Short Term Heap HeapShortTerm |
The number of bytes currently in use by the CLR's short-term heap. The Short Term Heap contains memory allocated by the CLR for temporary use. |
MinMax |
JIT Heap HeapJitCodeBuffer |
The number of bytes in use by the JIT compiler's heap. The JIT Heap contains the native code generated when the .NET Compact Framework JIT compiler compiles a managed method. JIT compilation occurs whenever a managed method is executed for the first time, or the first time a method is executed after code is discarded. |
MinMax |
App Domain Heap HeapAppDomain |
The number of bytes in use by the CLR's application domain heap. The App Domain Heap contains the dynamic representation of metadata used by the CLR's assembly loader. |
MinMax |
GC Heap HeapGC |
The number of bytes in use by the garbage collector heap. The GC Heap contains memory allocated by applications and the .NET Compact Framework. |
MinMax |
JIT Compilation Counters
The following counters pertain to JIT compiler operations.
Name and short name | Description | Counter type |
---|---|---|
Native Bytes Jitted cbJittedNative |
The count of bytes of native code generated by the JIT compiler. |
Complex |
Methods Jitted nMethodsJitted |
The count of methods generated by the JIT compiler. |
Simple |
Bytes Pitched cbPitched |
The count of bytes of native code generated by the JIT compiler that has been discarded. |
Complex |
Methods Pitched nMethodsPitched |
The count of methods generated by the JIT compiler that have been discarded. Unless your application was moved to the background during its run time, any positive value for the Methods Pitched counter indicates that the application ran under memory pressure. |
Simple |
Method Pitch Latency Time (ms) msPitchLatency |
The total time, in milliseconds, spent discarding methods generated by the JIT compiler. |
Complex |
Exceptions Counters
The following counters pertain to exceptions.
Name and short name | Description |
---|---|
Exceptions Thrown nExceptions |
The count of managed exceptions that have been thrown. Because throwing an exception consumes significant resources, tracking the number of exceptions thrown by your application can help identify potential design issues. |
Interop Counters
The following counters pertain to interoperability with native code.
Name and short name | Description | Counter type |
---|---|---|
Platform Invoke Calls nPInvoke |
The count of platform invoke calls from managed code to native code, excluding internal CLR platform invoke calls. |
Simple |
COM Calls Using a vtable nComVTable |
The count of calls from managed code to native code using the COM interop vtable method. |
Simple |
COM Calls Using IDispatch nComIDispatch |
The count of calls from managed code to native code using the COM interop IDispatch method. |
Simple |
Complex Marshaling nMarshal |
The number of objects marshaled from managed code to native code that involved copying or transforming the data. |
Simple |
Runtime Callable Wrappers cTotalRcw |
The total count of COM runtime callable wrappers that have been created. Runtime callable wrappers are created when managed code running on the .NET Compact Framework runtime calls into an unmanaged COM object. |
Simple |
Networking Counters
The following counters pertain to network send and receive operations.
Name and short name | Description | Counter type |
---|---|---|
Socket Bytes Sent nBytesSent |
The total count of bytes sent over sockets. |
Simple |
Socket Bytes Received nBytesReceived |
The total count of bytes received over sockets. |
Simple |
Windows Forms Counters
The following counters pertain to the System.Windows.Forms namespace.
Name and short name | Description | Counter type |
---|---|---|
Controls Created nControlsCreated |
The total number of controls created by the application. |
Simple |
Brushes Created nBrushesCreated |
The total number of brush objects created by the application. |
Simple |
Pens Created nPensCreated |
The total number of pen objects created by the application. |
Simple |
Bitmaps Created nBitmapsCreated |
The total number of bitmap objects created by the application. |
Simple |
Regions Created nRegionsCreated |
The total number of region objects created by the application. |
Simple |
Fonts Created nFontsCreated |
The total number of font objects created by the application. |
Simple |
Graphics Created (FromImage) nGraphicsFromImage |
The total number of graphics objects created by the FromImage method. |
Simple |
Graphics Created (CreateGraphics) nGraphicsCreateGraphics |
The total number of graphics objects created by the CreateGraphics method. |
Simple |
See Also
Tasks
How to: Generate Performance Statistics