diff --git a/Changes.txt b/Changes.txt index 026b373196..c03a8b7fb6 100644 --- a/Changes.txt +++ b/Changes.txt @@ -1,3 +1,5 @@ +- fixed #146 - Changed Performance Counter InstanceLifetime + 3.3.0 ================== - implemented #57 - build NuGet and Zip packages from TeamCity - contributed by Blair Conrad (@blairconrad) diff --git a/docs/performance-counters.md b/docs/performance-counters.md index a9c2280ffb..627dc6e29e 100644 --- a/docs/performance-counters.md +++ b/docs/performance-counters.md @@ -17,7 +17,7 @@ var counter = LifecycledComponentsReleasePolicy.GetTrackedComponentsPerformanceC container.Kernel.ReleasePolicy = new LifecycledComponentsReleasePolicy(diagnostic, counter); ``` -Then Windsor will inspect if it has all required permissions, and if it does, it will ensure the right category and counters are created and will update the counter as the application(s) run. +Then Windsor will inspect if it has all required permissions, and if it does, it will ensure the right category and counters are created and will update the counter as the application(s) run. The created counter instances will exist for the lifetime of the process and will be removed when the process closes. In order to see the data open Performance Monitor (part of Computer Management console accessible from Administrative Tools section of your Windows Control Panel). Then click Add (Ctrl+N) and find "Castle Windsor" section. As noted above it will contain just one counter - "Objects tracked by release policy", and list of its instances. @@ -29,4 +29,4 @@ For example on the image above you can see there are two instances of the counte List of tracked instances in each container: -![](images/perf-counter-instances.png) \ No newline at end of file +![](images/perf-counter-instances.png) diff --git a/src/Castle.Windsor/Windsor/Diagnostics/PerformanceMetricsFactory.cs b/src/Castle.Windsor/Windsor/Diagnostics/PerformanceMetricsFactory.cs index d2c582fc1f..a49b31f1b1 100644 --- a/src/Castle.Windsor/Windsor/Diagnostics/PerformanceMetricsFactory.cs +++ b/src/Castle.Windsor/Windsor/Diagnostics/PerformanceMetricsFactory.cs @@ -55,10 +55,15 @@ private PerformanceCounter BuildInstancesTrackedByReleasePolicyCounter(string na } try { - return new PerformanceCounter(CastleWindsorCategoryName, - InstanesTrackedByTheReleasePolicyCounterName, - name, - readOnly: false) { RawValue = 0L }; + return new PerformanceCounter + { + CategoryName = CastleWindsorCategoryName, + CounterName = InstanesTrackedByTheReleasePolicyCounterName, + InstanceName = name, + ReadOnly = false, + InstanceLifetime = PerformanceCounterInstanceLifetime.Process, + RawValue = 0L // Setting RawValue will initialize the counter so it must be set last + }; } // exception types we should expect according to http://msdn.microsoft.com/en-us/library/356cx381.aspx catch (Win32Exception)