We have an application that monitors remote directories for change notifications using ReadDirectoryChangesW() . According to Microsoft documentation, each outstanding change notification request consumes a "work item" resource on the server. I have a test which monitors hundreds of directories, on a Windows Server 2003 (32-bit) machine. It fails consistently when the number of directories is above a certain value, around 120, at which point an event is logged on the server saying something like:

The server was unable to allocate a work item 2 times in the last 60 seconds.

When this happens, the connection is dropped, and perfmon shows that a "Work Item Shortage" has occurred.

Articles here and there indicate that the number of work items can be increased by setting the MaxWorkItems registry key. However, it's unclear to me whether this applies to Windows Server 2003. I've tried setting this key (along with MaxMpxCt) to higher values, on the order of several thousand, and restarting the Server service (and also rebooting). However, perfmon always shows "Available Work Items" to be somewhere in the neighborhood of 120-160. When I run my test program, this number drops, predictably, until it hits zero, a shortage is logged, and the connection to my client is dropped.

My question is: Can I affect the number of available work items in my setup, and if so, how? And can I also do this for other versions of Windows we might be using (i.e. Server 2008, etc.)?

For the record, I've also tried playing with MinFreeWorkItems, InitWorkItems, MaxRawWorkItems, and MaxCmds, all to no avail.



Yes it does. MS recommend the 8000 limit but these are for the work item queue. We have increased this to 16000 in the past but we quicky ran out of non paged pool memory as 32bit has a hard limit of 256mb of this. We had MS in and they stated that whilst you can increase work items to 64000 technically it is not a good idea and they strongly suggested we limit it back to 8000.

The other issue this caused was as items where queued things that rely on processing them failed. Things such as file deletes, ms cluster heart beats. We had instances of files being deleted but reappearing as the work item wasnt processed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.