1

Is there anyway to get information about how many Garbage collection been performed for different generations from a dump file. When I try to run some psscor4 commands I get following.

0:003> !GCUsage
The garbage collector data structures are not in a valid state for traversal.
It is either in the "plan phase," where objects are being moved around, or
we are at the initialization or shutdown of the gc heap. Commands related to 
displaying, finding or traversing objects as well as gc heap segments may not 
work properly. !dumpheap and !verifyheap may incorrectly complain of heap 
consistency errors.
Error: Requesting GC Heap data
0:003> !CLRUsage
The garbage collector data structures are not in a valid state for traversal.
It is either in the "plan phase," where objects are being moved around, or
we are at the initialization or shutdown of the gc heap. Commands related to 
displaying, finding or traversing objects as well as gc heap segments may not 
work properly. !dumpheap and !verifyheap may incorrectly complain of heap 
consistency errors.
Error: Requesting GC Heap data

I can get output from eehpeap though, but it does not give me what I am looking for.

0:003> !EEHeap -gc
Number of GC Heaps: 1
generation 0 starts at 0x0000000002c81030
generation 1 starts at 0x0000000002c81018
generation 2 starts at 0x0000000002c81000
ephemeral segment allocation context: none
 segment     begin allocated  size
0000000002c80000  0000000002c81000  0000000002c87fe8  0x6fe8(28648)
Large object heap starts at 0x0000000012c81000
 segment     begin allocated  size
0000000012c80000  0000000012c81000  0000000012c9e358  0x1d358(119640)
Total Size:              Size: 0x24340 (148288) bytes.
------------------------------
GC Heap Size:            Size: 0x24340 (148288) bytes.
whoami
  • 1,689
  • 3
  • 22
  • 45
  • I don't believe that information is captured in a dump, and even if it was I fail to see how the number of collects is helpful. What are you investigating? – Brian Rasmussen Sep 22 '14 at 17:28
  • Want get idea of how much pressure was on GC and how frequently was it used. – whoami Sep 22 '14 at 17:29
  • Just to clarify. I didn't down vote. The number of GCs depends on both pressure and how long the process has been running, so I don't see how you can get much useful information from that number. – Brian Rasmussen Sep 22 '14 at 17:31
  • So we can know from dump file how long the process is up for. My thought was that if somehow I can determine how many times GC collections has been performed, I can establish some base line that could be compared with other scenarios to get some idea of memory pressure. – whoami Sep 22 '14 at 17:38
  • What is the problem you're troubleshooting? If you believe the answer was "yes there was some memory pressure", how much closer are you to solving that problem? From the numbers above your managed heap is tiny. What makes you think there's a memory issue? – Brian Rasmussen Sep 22 '14 at 17:56
  • All I want to know if any information related to # of GC performed can be achieved from a dump file. The question is not specific to sample output provided, – whoami Sep 22 '14 at 18:24
  • See related [Why PSSCOR4 command will not run](http://stackoverflow.com/questions/25980945/why-psscor4-command-will-not-run) why PSSCOR4 does not give results. – Thomas Weller Sep 22 '14 at 20:21
  • FYI: a potential reason for the downvote is that the PSSCOR commands don't show output. There seems to be no effort spent into making these commands work. If those commands would have worked, they still would not show a number of GC collections performed. – Thomas Weller Sep 22 '14 at 20:33

1 Answers1

1

Dumps

You can see the number of garbage collections in performance monitor. However, the way performance counters work makes me believe that this information is not available in a dump file and probably even not available during live debugging.

Think of Debug.WriteLine(): once the text was written to the debug output, it is gone. If you didn't have DebugView running at the time, the information is lost. And that's good, otherwise it would look like a memory leak.

Performance counters (as I understand them) work in a similar fashion. Various "pings" are sent out for someone else (the performance monitor) to be recorded. If noone does, the ping with all its information is gone.

Live debugging

As already mentioned, you can try performance monitor. If you prefer WinDbg, you can use sxe clrn to see garbage collections happen.

PSSCOR

The commands you mentioned, do not show information about garbage collection count:

0:016> !gcusage
Number of GC Heaps: 1
------------------------------
GC Heap Size          0x36d498(3,593,368)
Total Commit Size  0000000000384000 (3 MB)
Total Reserved Size  0000000017c7c000 (380 MB)

0:016> !clrusage
Number of GC Heaps: 1
------------------------------
GC Heap Size          0x36d498(3,593,368)
Total Commit Size  0000000000384000 (3 MB)
Total Reserved Size  0000000017c7c000 (380 MB)

Note: I'm using PSSCOR2 here, since I have the same .NET 4.5 issue on this machine. But I expect the output of PSSCOR4 to be similar.

Community
  • 1
  • 1
Thomas Weller
  • 55,411
  • 20
  • 125
  • 222
  • Thanks for the detailed response. Just as a side question (may be I should create a new one??) what's the diff between output of gcusage and clrusage. Looks exactly same here. May be difference is shown when there are more than one GC heaps? – whoami Sep 22 '14 at 20:56
  • @johnsmith: Sorry, I don't exactly know. I assume they are just synonyms like `!do` and `!dumpobj`. At least they both accept a `-v` switch and still produce the same output. `!gcusage` seems undocumented. It is not listed in `!help`. How did you know about it? – Thomas Weller Sep 22 '14 at 21:26
  • You are right, its undocumented. Found about it at http://naveensrinivasan.com/2010/04/03/undocumented-psscor2-functions/ – whoami Sep 23 '14 at 00:01