How to turn GCStress on in Windows 7?
Asked Answered
W

1

8

I am debugging a GC heap corruption and came to the step where I want to try running the program under WinDbg + PageHeap + AppVerifier + GCStress.

I found in the article Software crash: faulting module mscorwks.dll, version 1.1.4322.2379 that I can enable GCStress like this:

reg.exe add "HKLM\SOFTWARE\Microsoft\.NETFramework" /f  /v HeapVerify  /t REG_DWORD  /d 1  
reg.exe add "HKLM\SOFTWARE\Microsoft\.NETFramework" /f  /v StressLog  /t REG_DWORD  /d 1  
reg.exe add "HKLM\SOFTWARE\Microsoft\.NETFramework" /f  /v GCStress  /t REG_DWORD  /d 3  
reg.exe add "HKLM\SOFTWARE\Microsoft\.NETFramework" /f  /v FastGcStress  /t REG_DWORD  /d 2

(I am trying this method. It takes the program forever to launch. I deleted the last two entries from the registry to have it work, probably something is wrong with the approach itself.)

Or the article Access Violation in .NET 4 Runtime in gc_heap::garbage_collect with no unmanaged modules described the other method:

(DWORD) StressLog = 1  
(DWORD) LogFacility = 0xffffffff  
(DWORD) StressLogSize = 65536

Which way is correct or is there another correct way?

Work answered 26/9, 2011 at 13:58 Comment(2)
I don't understand the question. You are asking how to turn it on, then say that you found you can enable it with the first method, but that doesn't work. Does the second method work?Irrupt
@KierenJohnstone, I didn't try the second method and I am not sure if either of these is correct. That is all I found over the web about GCStress and I would like people proficient in the subject to advise. I wrote that the first method is slow because I may think that probably it could be made faster by setting other values for the specified registry keys.Work
D
0

I searched GCStress on Koders. It turned out the best way to understand it is by looking at .NET's source code:

enum  GCStressFlags {
    GCSTRESS_NONE               = 0,
    GCSTRESS_ALLOC              = 1,    // GC on all allocations and 'easy' places
    GCSTRESS_TRANSITION         = 2,    // GC on transitions to preemtive GC
    GCSTRESS_INSTR_JIT          = 4,    // GC on every allowable JITed instruction
    GCSTRESS_INSTR_NGEN         = 8,    // GC on every allowable NGEN instruction
    GCSTRESS_UNIQUE             = 16,   // GC only on a unique stack trace
};
Dubitation answered 10/2, 2012 at 15:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.