Reputation: 304
I've got a problem where I'm running a background process using mono 3.0.3 on a SLES box, and while using top I discovered that it's using 100% CPU. I searched and have tried the following possible solutions:
1) Setting the MONO_THREADS_PER_CPU environment variable to 1000, i.e.
export MONO_THREADS_PER_CPU=1000
This did not work. I tried with 300, per this thread, but that did not work, either.
2) According to this stackoverflow post, using Timers in the program to be executed using mono might cause high CPU load, however I made a very simple test program with just an infinite loop and ran it... and mono still had 100% CPU usage.
This is the program I used to test whether it was simply due to using Timers:
static void Main(string[] args)
{
while(true)
{
//Console.WriteLine("Stayin alive.");
}
}
3) I thought perhaps this was an issue in mono 3.0.3, so I upgraded to 3.6.0, which is apparently the latest version recommended for SLES 11.3. Mono still takes up 99-100% CPU.
So I'm left wondering what is going on and how can I fix this issue. Any help is very much appreciated.
Upvotes: 2
Views: 8330
Reputation: 3582
Limiting CPU would need to be set at the linux level. For example:
example
cpulimit -l 50 COMMAND
Otherwise, there is likely a bug in the code causing this that needs to be fixed (e.g. infinite loops).
Upvotes: 1