Is it really that expensive to increase FileSystemWatcher.InternalBufferSize?

后端 未结 3 412
感情败类
感情败类 2021-01-04 09:57

I\'m using a FileSystemWatcher to monitor changes in a folder, but as soon as I have more than a few hundred modifications in a short time, I miss some of them

3条回答
  •  不知归路
    2021-01-04 10:26

    Non-paged memory has limited size (update: modern versions of Windows don't have as strict limit as in previous versions, and the amount of memory is now a flexible value that depends on the overall RAM available to Windows) and is very important to kernel-mode inhabitants (device drivers, OS itself). Consuming it without severe control can quickly cause instability in the system and, what is worse, you won't find what has caused this instability.

    Also, as comments suggest, it's not the buffer size that matters, but how fast you remove data from the buffer.

    In most cases, a filesystem filter driver will do a better job than FileSystemWatcher. The benefits are that you can have any log buffer that you need (as you would create it in whatever memory you need and not be limited by non-paged memory) and also you can handle events as they happen, not after they happen. Also, you can filter requests with finer granularity than FileSystemWatcher lets you.

提交回复
热议问题