Skip to content

Commit

Permalink
Merge pull request #149 from mackenzieajudd/master
Browse files Browse the repository at this point in the history
Fix for issue #146: Performance Counter Instances Never Removed
  • Loading branch information
jonorossi authored Sep 22, 2016
2 parents aa9b8b3 + a24eaec commit 4a791f9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 2 additions & 0 deletions Changes.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
4 changes: 2 additions & 2 deletions docs/performance-counters.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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)
![](images/perf-counter-instances.png)
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4a791f9

Please sign in to comment.