Monday, February 18, 2008

Mono performance with Timers

Am I just imagining things, or does a basic C# Mono application that uses Timers "leak" CPU time? I have this application that spends most of its time idle. I added in a part that triggers a timer once per day. Now the application twiddles away tiny bits of CPU time from 0.3% to 1% pretty much continuously. After a few days, it's got many minutes of CPU time accumulated.

Normally I wouldn't worry about it. But this application is running on a machine that uses Asterisk, and voice quality is of paramount importance. So I want that machine running as lean as possible.

Update: I found that I had a
#define TRACE
in my code, because I'm using a trace listener for logging. The .NET docs say that you need a #define TRACE for trace listeners to work. Turns out, you really don't. Trace listeners still work without that. And for some reason, the application takes a lot less CPU time without that, but still works.

No comments: