none
FileSystemWatcher insufficient resources win server2008 RRS feed

  • Question

  • Hi,

    We are getting errors from a .NET application that is using the filesystemwatcher. We are in the process of migrating it from win server 2003 to win server 2008. 

    The error we get is: System.ComponentModel.Win32Exception: Insufficient system resources exist to complete the requested service

    The application creates over 100 new threads and each containing a filewatcher event and does other processing work with the picked-up file. It worked fine in win2003 but on win2008 we start to get the above error when creates beyond 50 threads. A few things which we noticed are:

    • each filewatcher monitors a UNC folder but when we change them to the local drive we don't get the error
    • works fine on windows 2003

    Our new server is windows server 2008 R2 Enterprise with SP1. I read that SP2 has a hotfix on memory leaks with the filewatcher. I'm wondering if this is the solution?

    https://blogs.technet.microsoft.com/yongrhee/2012/05/05/list-of-memory-leaks-related-hotfixes-post-sp2-for-windows-vista-sp2-and-windows-server-2008-sp2/

    Here is the stripped down version of our code. It really is simply spawning threads for each filewatcher.

    static void Main(string[] args)
    {
    Console.WriteLine("Starting create watcher thread...");

    try
    {
    XmlNode feedSettings = (XmlNode)ConfigurationManager.GetSection("GatewayService/Adapters");
    foreach (XmlNode node in feedSettings.ChildNodes)
    {
    Thread thread = new Thread(new ThreadStart(new A(node).CreateWatcher));
    thread.Start();
    }

    Console.WriteLine("Totally created {0} watchers...", feedSettings.ChildNodes.Count);
    }
    catch (Exception ex)
    {
    Console.WriteLine("FileListener: Error occurred:", ex.Message);
    }

    Console.Read();

    }

    public void CreateWatcher()
    {

    FileSystemWatcher Watcher = new FileSystemWatcher();



    XmlNode pollDirectory = node.SelectSingleNode("PollDirectory");

    if (pollDirectory == null)
    throw new ArgumentException("PollDirectory is null.");

    Watcher.Path = pollDirectory.InnerText;//"c:\\temp\\poll" ;//put your folder to watch here
    Watcher.Filter = "*.txt";//"def*.*"; 
    Watcher.NotifyFilter = NotifyFilters.DirectoryName;
    Watcher.NotifyFilter = Watcher.NotifyFilter | NotifyFilters.FileName;


    //add the handler to each event               
    //Watcher.Created += new FileSystemEventHandler(this.Created);
    Watcher.Error += new ErrorEventHandler(WatcherErrorHandler);

    //Set this property to true to start watching
    Watcher.EnableRaisingEvents = true;
    }

    Thanks

    stephen

     

    Wednesday, March 30, 2016 4:50 AM

All replies

  • Hi Stephen,

    >>The error we get is: System.ComponentModel.Win32Exception: Insufficient system resources exist to complete the requested service

    it almost sounds like there is a memory leak in some applications you have running in the background; it is using memory for something then not clearing it out afterwards.
    then ctrl + alt + del will bring up the Task Manager.  Click on 'Performance' tab.  Look under Physical Memory and tell us the numbers for Total and Available.

    In addition, please also compare your two machines(win2k3 and win2008).

    >>Our new server is windows server 2008 R2 Enterprise with SP1. I read that SP2 has a hotfix on memory leaks with the filewatcher. I'm wondering if this is the solution?

    You also could have a try, I am not sure you could do.

    Here is also a support kB that related to your Registry Size Limit, please have a try.

    https://support.microsoft.com/en-us/kb/2567018

    In addition, I also suggest you use Process Monitor to monitor your System process.

    Best regards,

    Kristin  


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Edited by Kristin Xie Thursday, March 31, 2016 2:50 AM
    Thursday, March 31, 2016 2:43 AM
  • Hi Kristin

    We have plenty of RAM. Our win 2008 servers are more powerful than our old 2003 and the application works fine on them rather than the new server. click here for the screenshot of task manager http://screenshot.net/w6kerup

    As you can see from the above code - it's a simple creating new threads for a filewatcher so i cant see any problems with it.

    Another thing we tested was the error happens on a Linus file server that the filewatcher monitors. When we switched the monitoring directory to a windows os it doesn't produce any error... 

    Thanks

    Stephen

    Thursday, March 31, 2016 8:21 AM
  • **** correction ****

    error happens on network paths only and disappears when monitoring local drive.

    Thursday, March 31, 2016 11:05 AM
  • Hi Kristin

    We have plenty of RAM. Our win 2008 servers are more powerful than our old 2003 and the application works fine on them rather than the new server. click here for the screenshot of task manager http://screenshot.net/w6kerup

    As you can see from the above code - it's a simple creating new threads for a filewatcher so i cant see any problems with it.

    Another thing we tested was the error happens on a Linus file server that the filewatcher monitors. When we switched the monitoring directory to a windows os it doesn't produce any error... 

    Thanks

    Stephen

    @Stephen,

    Based on your description, this issue more related to your win server2008. Since I don't have this machine, I cannot help you do a test.

    To make sure if this is a issue related to Win Server 2008 r2, I would suggest you make the following test.

    1. How about the result on win2008 clean machine?
    2. Windows Server 2008 R2 is currently available in seven editions:
    • Windows Server 2008 R2 Web
    • Windows Server 2008 R2 Standard
    • Windows Server 2008 R2 Enterprise
    • Windows Server 2008 R2 Datacenter
    • Windows Server 2008 R2 Itanium
    • Windows Server 2008 R2 Foundation
    • Windows Server 2008 R2 HPC

    Only Windows Server 2008 R2 Enterprise has this issue?

    Please let me know the results. After you confirm this issue only related to Win Server 2008 r2, you could submit this issue to MS connect that support engineer from MS will help you resolve it.

    Best regards,

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, April 5, 2016 9:40 AM