none
Windows Service .NET running on CLR 4.0 High CPU Usage

    Question

  • We have a windows service which hosts different appdomains. This processes uses remoting over IPC and TCP to communicate across the different app domains and with other processes.

     

    This process is compiled using .NET framework 2.0 (vs2005) but we forced it to run on CLR 4.0 using the following entry in the config file.

      <startup useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v4.0"/>
      </startup>

     

    The problem is that after some hours of running, the process starts eating up the CPU cycles. When debugging with WINDBG we notice that the thread consuming much of the CPU is in fact the Garbage Collector (<gcServer> is set to true).

     

    On inspection of the Heap we notice that there is a very huge array on the LOH of the type System.LocalDataStoreElement with around 18million entries all set to null. This array is copied and increased each time, which is what is causing the cpu issue.

    Now in our services we are passing Identities to impersonate user in the other appdomains / processes in the Named dataslots for the different threads (we have an object which implements the ILogicalThreadAffinative).

     

    This issue is not present if the process runs on the CLR 2.0. Anybody can shed to us some light of what we are doing wrong or what changed in the CLR 4.0 please?

     

    thanks

     

     

    Thursday, May 19, 2011 12:48 PM

All replies