{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/coreclr/issues/588","labels_url":"https://api.github.com/repos/dotnet/coreclr/issues/588/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/coreclr/issues/588/comments","events_url":"https://api.github.com/repos/dotnet/coreclr/issues/588/events","html_url":"https://github.com/dotnet/coreclr/issues/588","id":64835900,"number":588,"title":"How to get GC logs?","user":{"login":"AndreyAkinshin","id":2259237,"avatar_url":"https://avatars.githubusercontent.com/u/2259237?v=3","gravatar_id":"","url":"https://api.github.com/users/AndreyAkinshin","html_url":"https://github.com/AndreyAkinshin","followers_url":"https://api.github.com/users/AndreyAkinshin/followers","following_url":"https://api.github.com/users/AndreyAkinshin/following{/other_user}","gists_url":"https://api.github.com/users/AndreyAkinshin/gists{/gist_id}","starred_url":"https://api.github.com/users/AndreyAkinshin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndreyAkinshin/subscriptions","organizations_url":"https://api.github.com/users/AndreyAkinshin/orgs","repos_url":"https://api.github.com/users/AndreyAkinshin/repos","events_url":"https://api.github.com/users/AndreyAkinshin/events{/privacy}","received_events_url":"https://api.github.com/users/AndreyAkinshin/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-03-27T19:27:31Z","updated_at":"2015-03-28T05:06:35Z","closed_at":"2015-03-28T05:06:35Z","body":"GC has some useful lines for logging. Examples:\r\n\r\n`coreclr\\src\\gc\\gc.cpp`\r\n\r\n```\r\nvoid GCStatistics::DisplayAndUpdate()\r\n{\r\n    LIMITED_METHOD_CONTRACT;\r\n\r\n    if (logFileName == NULL || logFile == NULL)\r\n        return;\r\n\r\n    {\r\n        if (cntDisplay == 0)\r\n            fprintf(logFile, \"\\nGCMix **** Initialize *****\\n\\n\");\r\n            \r\n        fprintf(logFile, \"GCMix **** Summary ***** %d\\n\", cntDisplay);\r\n\r\n        // NGC summary (total, timing info)\r\n        ngc.DisplayAndUpdate(logFile, \"NGC \", &g_LastGCStatistics.ngc, cntNGC, g_LastGCStatistics.cntNGC, msec);\r\n\r\n        // FGC summary (total, timing info)\r\n        fgc.DisplayAndUpdate(logFile, \"FGC \", &g_LastGCStatistics.fgc, cntFGC, g_LastGCStatistics.cntFGC, msec);\r\n\r\n        // BGC summary\r\n        bgc.DisplayAndUpdate(logFile, \"BGC \", &g_LastGCStatistics.bgc, cntBGC, g_LastGCStatistics.cntBGC, msec);\r\n```\r\n\r\n`coreclr\\src\\gc\\handletable.cpp`\r\n\r\n```\r\nvoid DEBUG_PostGCScanHandler(HandleTable *pTable, const UINT *types, UINT typeCount, UINT condemned, UINT maxgen, ScanCallbackInfo *info)\r\n{\r\n    LIMITED_METHOD_CONTRACT;\r\n\r\n    // looks like the GC supports more generations than we expected\r\n    _ASSERTE(condemned < MAXSTATGEN);\r\n\r\n    // remember the highest generation we've seen\r\n    if (pTable->_DEBUG_iMaxGen < (int)condemned)\r\n        pTable->_DEBUG_iMaxGen = (int)condemned;\r\n\r\n    // update the statistics\r\n    pTable->_DEBUG_TotalBlocksScanned                [condemned] += info->DEBUG_BlocksScanned;\r\n    pTable->_DEBUG_TotalBlocksScannedNonTrivially    [condemned] += info->DEBUG_BlocksScannedNonTrivially;\r\n    pTable->_DEBUG_TotalHandleSlotsScanned           [condemned] += info->DEBUG_HandleSlotsScanned;\r\n    pTable->_DEBUG_TotalHandlesActuallyScanned       [condemned] += info->DEBUG_HandlesActuallyScanned;\r\n\r\n    // if this is an ephemeral GC then dump ephemeral stats for this scan right now\r\n    if (condemned < maxgen)\r\n    {\r\n        // dump a header for the stats with the condemned generation number\r\n        LOG((LF_GC, LL_INFO1000, \"--------------------------------------------------------------\\n\"));\r\n        LOG((LF_GC, LL_INFO1000, \"Ephemeral Handle Scan Summary:\\n\"));\r\n        LOG((LF_GC, LL_INFO1000, \"    Generation            = %u\\n\", condemned));\r\n\r\n        // dump the handle types we were asked to scan\r\n        LOG((LF_GC, LL_INFO1000, \"    Handle Type(s)        = %u\", *types));\r\n        for (UINT u = 1; u < typeCount; u++)\r\n            LOG((LF_GC, LL_INFO1000, \",%u\", types[u]));\r\n        LOG((LF_GC, LL_INFO1000,  \"\\n\"));\r\n\r\n        // dump the number of blocks and slots we scanned\r\n        ULONG32 blockHandles = info->DEBUG_BlocksScanned * HANDLE_HANDLES_PER_BLOCK;\r\n        LOG((LF_GC, LL_INFO1000, \"    Blocks Scanned        = %u (%u slots)\\n\", info->DEBUG_BlocksScanned, blockHandles));\r\n```\r\n\r\nWhat the best way to get the debug GC logs?"},"comment":{"url":"https://api.github.com/repos/dotnet/coreclr/issues/comments/87162172","html_url":"https://github.com/dotnet/coreclr/issues/588#issuecomment-87162172","issue_url":"https://api.github.com/repos/dotnet/coreclr/issues/588","id":87162172,"user":{"login":"AndreyAkinshin","id":2259237,"avatar_url":"https://avatars.githubusercontent.com/u/2259237?v=3","gravatar_id":"","url":"https://api.github.com/users/AndreyAkinshin","html_url":"https://github.com/AndreyAkinshin","followers_url":"https://api.github.com/users/AndreyAkinshin/followers","following_url":"https://api.github.com/users/AndreyAkinshin/following{/other_user}","gists_url":"https://api.github.com/users/AndreyAkinshin/gists{/gist_id}","starred_url":"https://api.github.com/users/AndreyAkinshin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndreyAkinshin/subscriptions","organizations_url":"https://api.github.com/users/AndreyAkinshin/orgs","repos_url":"https://api.github.com/users/AndreyAkinshin/repos","events_url":"https://api.github.com/users/AndreyAkinshin/events{/privacy}","received_events_url":"https://api.github.com/users/AndreyAkinshin/received_events","type":"User","site_admin":false},"created_at":"2015-03-28T05:06:35Z","updated_at":"2015-03-28T05:06:35Z","body":"@brianrob, thanks!"}}