Welcome Guest, you are in: Login

Castle Project


Navigation (Windsor)

Search the wiki


This documentation is a work in progress.

Let us know if some information is not clear, inaccurate or missing. Also feel free to update the wiki yourself.

Performance Counters

Modified on 2012/06/23 00:38 by Krzysztof Ko┼║mic Categorized as Wawel, Work_In_Progress
Windsor 3 introduces support for Windows performance counters.

Currently Windsor publishes just one counter - "Objects tracked by release policy", which shows you the total number of objects tracked by release policy of given container.
Hunting memory leaks

This is a very useful feature, that will help you quickly validate if you have problems with non-releasing tracked component instances.

Using counters

This feature is not enabled by default. The following code shows how you can enable it:

var container = new WindsorContainer();
var diagnostic = LifecycledComponentsReleasePolicy.GetTrackedComponentsDiagnostic(container.Kernel);
var counter = LifecycledComponentsReleasePolicy.GetTrackedComponentsPerformanceCounter(new PerformanceMetricsFactory());
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.

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.

List of instances of Windsor performance counter

For example on the image above you can see there are two instances of the counter. Each of them comes from separate instance of the same application. After you select them you will be able to track, live, total number of all tracked component instances in each of the containers.

List of tracked instances in each container

ScrewTurn Wiki version Some of the icons created by FamFamFam.