Build high performanceASP. NETSite Chapter 7 How to solve memory problems(Previous)-Managed Resource Optimization-MonitoringCLRPerformance
In the previous articleArticleThis article describes how to monitorCLRWhether it causes some performance problems.
The topics in this article are as follows:
Memory problems(Previous)
Managed Resource Optimization (previous)
Object lifecycle (previous)
Object"Generation "(previous)
Large Object heap(LOH)(Previous)
CLRCounter usage(Part 1)
CLR profiler(Part I)
Different versions of the garbage collector (Part 1)
Object usage considerations (later)
Common optimization measures (Part II)
Optimization of unmanaged Resources
SessionSession Optimization
Links to articles:
Build high performanceASP. NETSite Opening
Build high performanceASP. NETOne site Analyze the page processing process (front-end)
Build high-performance ASP. Net Site 2 optimize HTTP requests (front-end)
Building a high-performance ASP. Net site depends on the three details
Building a high-performance ASP. Net Site Chapter 5-Performance Tuning Overview (previous)
Design of large-scale high-performance ASP. NET System Architecture
Building a high-performance ASP. Net Site Chapter 5-Performance Tuning Overview (Part 1)
Building a high-performance ASP. Net Site Chapter 5-Performance Tuning Overview (Part II)
Building a high-performance ASP. Net Site Chapter 6-performance bottleneck diagnosis and preliminary optimization (Part 1)-identifying performance bottlenecks
Build a high-performance ASP. Net Site Chapter 6-performance bottleneck diagnosis and preliminary optimization (next article)-simple Optimization Measures
Building a high-performance ASP. Net Site Chapter 6-performance bottleneck diagnosis and preliminary optimization (next article)-reducing unnecessary requests
Building a high-performance ASP. Net Site Chapter 7 how to solve memory problems (previous article)-Managed Resource Optimization-in-depth analysis of the garbage collection mechanism
Building a high-performance ASP. Net Site Chapter 7 how to solve memory problems (previous article)-Managed Resource Optimization-monitor CLR Performance
CLRCounter usage
We use the built-in performance monitoring tool to track and monitor the garbage collector.
Next, we will first introduce several commonCLRPerformance monitoring counters. Net CLR memoryCounters Under classification:
Percent Time in GC |
indicates the percentage of the total time taken to run the garbage collection mechanism from the last time it was run. 10% . |
Gen 0 heap size |
This value does not indicate the size of the Gen 0 object in the current managed heap, but refers: Gen 0 object size |
Gen 1 heap size |
indicates the current Gen 1 size of the managed heap space occupied by objects |
Gen 2 heap size |
indicates the current Gen 2 size of the managed heap space occupied by objects |
large object heap size |
current LOH size |
# byte in all heaps |
above Gen 0 heap size , Gen 1 heap size , Gen 2 heap size , large object heap size all types and, that is, the space occupied by the entire managed heap |
# Gen 0 collections |
after the system is enabled, garbage Collector recycle Gen 0 Number of objects |
# Gen 1 collections |
after the system is enabled, garbage Collector recycle Gen 1 Number of objects |
# Gen 2 collections |
After the system is enabled, the garbage collector recyclesGen 2Number of Objects |
After introducing some of the counters above, you can run"Perfmon"Command to open the performance monitoring tool.
Next we will start to introduceCLR profiler(CLRDialysis machine)
CLR profiler
CLR profilerIs a tool developed by Microsoft. This tool can be used to detectCLRMemory usage details.
You can download this tool at the following link:
Http://www.microsoft.com/downloads/details.aspx? Familyid = a362781c-3870-43be-8926-862b40aa0cd0 & displaylang = en
The following link details the usage of this tool:
Http://msdn.microsoft.com/zh-cn/magazine/ee309515.aspx#MtViewDropDownText
Here, we will briefly introduce how to use it. For detailed operations, please refer to the above link. The procedure is as follows:
1.RunCLR proflier
2.Ensure"Profiling active, allocations, CILS"Select. As follows:
3.Select"File-> profile ASP. NET".The operation is stopped.IIS, Insert some commands, and then restartIISSo this tool is used with caution in the production environment.
4.Then we canVSMediumF5Run our website(Make sure thatIISInstead of selecting"File System"Is created)
5.Click"Kill ASP. NET ".After this operation is performedIISSome monitoring commands in. After you click the button, some interfaces are displayed. This interface showsGen0, gen1 gen2, LohAs follows:
6.You can also click"Histogram"Button. This interface shows the proportions of objects of different sizes and types. We can see that there are manyStringObject, that is,StringObjects of the type occupy most of the system's memory space.
For more information, see the version of the garbage collector.
Version of the Garbage Collector
InCLRThe garbage collector has two versions:
1.Server version.CLRThis version of the garbage collector in has carried out a series of memory and processor Optimizations to further improve performance.
2.Working Group version, which is relative to the server version and mainly used in desktop development. For exampleWPF,WinformThe version of the garbage collector is used.
InASP. NETIs usedCLRThe server version of the garbage collector.
OKToday, I am writing it here. The next article describes some optimization measures for the above problems.