none
Handle counts not getting cleaned up and rising up to ~100000 RRS feed

  • Question

  • We are facing with an issue for which root cause is still unknown to us :

    Our server configuration is as follows :

    32 Core 2.4 Ghz
    Windows 2012 Server(Windows NT 6.2 64 Bit)
    128 GB RAM
    55 TB Hardisk Drive

    The issue :

    We recently figured out that for one of the service running on this box the handles count goes on increasing. Did some dump analysis using the WinDbg tool to find the handles were Event handles.

    • One strange is that if we make a call to "GC.Collect", then the handles drop back to normal values. For example : If I leave the service running for 1 hour the handle count is ~30K. And after making call to GC.Collect() it drops to ~700.
    • The same service works fine on my other machine with comparatively less configuration. Why is the garbage collector not getting called automatically to collect the handles. 

      We faced a critical issue cause of this. It seems like the service used a large number of handles >~100000 and due to this one of the service was not able to access the 55TB hardisk.

      Anyone know something about this ?
    Tuesday, September 8, 2015 6:10 AM

Answers

  • You're probably not disposing some objects. And if by "less configuration" you mean less memory then it's likely that on the machine which has less memory GC runs more often and thus the issue is avoided. But it's really not GC's job to cleanup disposable objects.
    Tuesday, September 8, 2015 7:45 AM
    Moderator

All replies

  • You're probably not disposing some objects. And if by "less configuration" you mean less memory then it's likely that on the machine which has less memory GC runs more often and thus the issue is avoided. But it's really not GC's job to cleanup disposable objects.
    Tuesday, September 8, 2015 7:45 AM
    Moderator
  • It is unlikely that 100K event handles will cause any issues. The kernel can cope with it easily. The problem you have is that you are allocating event handles but no one ever disposes it leaving them to the next full GC when the finalizer is woken up to clean up all finalizable objects.

    You need to to identify the code path where the handles are allocated and close them before they go out of scope. You can take a memory dump and search of all roots of WaitHandles or EventWaitHandles, Manual and AutoResetEvent instances. This should give you some hints who was owning them before the object graph did go out of scope.

    Monday, September 14, 2015 7:17 PM