I have a service using WCF. Inside it has a dictionary with lists that you can add or get a subset of from different endpoints.
The code looks something like this:
List<Data> list = null;
try
{
locker.EnterReadLock();
list = internalData[Something].Where(x => x.hassomething()).ToList();
}
finally
{
locker.ExitReadLock();
}
foreach (var y in list)
{
result[y.proprty1].Add(y.property2);
}
return result;
Thus, internalData is blocked by ReaderWriterLockSlim for all operations, the reader to read and write to add. I make a copy of the elements inside the castle and work on this copy later.
The problem arises after a while, more and more processor cores go 100% and, finally, use all the cores. It can work perfectly for several days and millions of calls until it stops.
, . , , .
- , , , - ?