Click here to Skip to main content
15,031,208 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Per DebugDiag:

The following threads in Zetta_160502_185436.dmp are waiting for .net garbage collection to finish. Thread 105 triggered the garbage collection.The gargage collector thread wont start doing its work till the time the threads which have pre-emptive GC disabled have finished executing. The following threads have pre-emptive GC disabled 105.

Thread 105 is the only thread that is not Preemptive. It is listed as Cooperative.

Looking at the call stack for thread 105, it makes a call to the PerformanceCounter NextValue() method, which ultimately calls RegistryKey.InternalGetValue. In that method it creates a large byte array, with a size of at least 65,000 bytes. I think this is where the additional memory is needed, hence triggering the garbage collection. Thing is, I don’t see anywhere that would be changing the GC Mode.

My questions are:

How can a given thread be waiting on itself before GC begins?

How did the GC Mode of the thread get changed to Cooperative?



What I have tried:

We keep getting out of memory exceptions because of this condition, but I don’t know what to change to fix it.
Patrice T 15-Jul-16 16:03pm
You should rather try to understand where and why you need so much memory.
Richard MacCutchan 16-Jul-16 4:16am
If your threads prevent GC from running then there is something wrong with your application. That is what you need to address and fix. You can call GC directly in one of your threads if necessary via System.GC.Collect(), although it is not recommended.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900