dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.03k stars 4.67k forks source link

help analyze a gcroot! #52230

Open ZhiqiangTao opened 3 years ago

ZhiqiangTao commented 3 years ago

recently, I meet an issue image as you can see, the gen2 is very large(about 120m) smaller than LOH, so I think there are many objects migrate from gen0 ->gen1-to gen2, then I use gcroot and gcwhere to inspect some objects , but i found that most of them are handled by below:

> gcwhere **00007fbb3510cca8**
Address            Gen   Heap   segment            begin              allocated           size
00007FBB3510CCA8   **2**     0     00007FBB33FFE000   00007FBB33FFF000   00007FBB3B5402D0    0x40(64)
> gcroot **00007fbb3510cca8**
Thread 1:
    00007FFD1E9D5C30 00007FBC8BE3F1D0 System.Threading.Tasks.Task.SpinThenBlockingWait(Int32, System.Threading.CancellationToken)
        rbp-30: 00007ffd1e9d5c50
            ->  00007FBB3454B598 System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.Threading.Tasks.VoidTaskResult, System.Private.CoreLib],[Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions+<RunAsync>d__4, Microsoft.Extensions.Hosting.Abstractions]]
            ->  00007FBB342373F0 Microsoft.Extensions.Hosting.Internal.Host
            ->  00007FBB34236360 Microsoft.Extensions.Logging.Logger`1[[Microsoft.Extensions.Hosting.Internal.Host, Microsoft.Extensions.Hosting]]
            ->  00007FBB34236480 Microsoft.Extensions.Logging.Logger
            ->  00007FBB342364A8 Microsoft.Extensions.Logging.LoggerInformation[]
            ->  00007FBB34236548 Microsoft.Extensions.Logging.Console.ConsoleLogger
            ->  00007FBB342309D8 Microsoft.Extensions.Logging.Console.SimpleConsoleFormatter
            ->  00007FBB34230BA8 Microsoft.Extensions.Options.OptionsMonitor`1+ChangeTrackerDisposable[[Microsoft.Extensions.Logging.Console.SimpleConsoleFormatterOptions, Microsoft.Extensions.Logging.Console]]
            ->  00007FBB34230810 Microsoft.Extensions.Options.OptionsMonitor`1[[Microsoft.Extensions.Logging.Console.SimpleConsoleFormatterOptions, Microsoft.Extensions.Logging.Console]]
            ->  00007FBB34230480 Microsoft.Extensions.Options.OptionsFactory`1[[Microsoft.Extensions.Logging.Console.SimpleConsoleFormatterOptions, Microsoft.Extensions.Logging.Console]]
            ->  00007FBB34230320 Microsoft.Extensions.Options.IConfigureOptions`1[[Microsoft.Extensions.Logging.Console.SimpleConsoleFormatterOptions, Microsoft.Extensions.Logging.Console]][]
            ->  00007FBB34230340 Microsoft.Extensions.Logging.ConsoleLoggerFormatterConfigureOptions`2[[Microsoft.Extensions.Logging.Console.SimpleConsoleFormatter, Microsoft.Extensions.Logging.Console],[Microsoft.Extensions.Logging.Console.SimpleConsoleFormatterOptions, Microsoft.Extensions.Logging.Console]]
            ->  00007FBB34230398 System.Action`1[[Microsoft.Extensions.Logging.Console.SimpleConsoleFormatterOptions, Microsoft.Extensions.Logging.Console]]
            ->  00007FBB34230380 Microsoft.Extensions.Options.ConfigureFromConfigurationOptions`1+<>c__DisplayClass0_0[[Microsoft.Extensions.Logging.Console.SimpleConsoleFormatterOptions, Microsoft.Extensions.Logging.Console]]
            ->  00007FBB34230358 Microsoft.Extensions.Configuration.ConfigurationSection
            ->  00007FBB3422C1D8 Microsoft.Extensions.Configuration.ConfigurationRoot
            ->  00007FBB3422C140 System.Collections.Generic.List`1[[Microsoft.Extensions.Configuration.IConfigurationProvider, Microsoft.Extensions.Configuration.Abstractions]]
            ->  00007FBB3422C180 Microsoft.Extensions.Configuration.IConfigurationProvider[]
            ->  00007FBB3422C160 Microsoft.Extensions.Configuration.ChainedConfigurationProvider
            ->  00007FBB3422C078 Microsoft.Extensions.Configuration.ConfigurationSection
            ->  00007FBB34029FC8 Microsoft.Extensions.Configuration.ConfigurationRoot
            ->  00007FBB34029FF0 Microsoft.Extensions.Configuration.ConfigurationReloadToken
            ->  00007FBB3402A008 System.Threading.CancellationTokenSource
            ->  00007FBB3422C368 System.Threading.CancellationTokenSource+CallbackPartition[]
            ->  00007FBB3422C3C0 System.Threading.CancellationTokenSource+CallbackPartition
            ->  00007FBB3454AD40 System.Threading.CancellationTokenSource+CallbackNode
            ->  00007FBB34546E08 System.Threading.CancellationTokenSource+CallbackNode
            ->  00007FBB342335E8 System.Threading.CancellationTokenSource+CallbackNode
            ->  00007FBB34233570 Microsoft.Extensions.Primitives.ChangeToken+ChangeTokenRegistration`1[[System.String, System.Private.CoreLib]]
            ->  00007FBB342334E8 System.Action`1[[System.String, System.Private.CoreLib]]
            ->  00007FBB34233438 Microsoft.Extensions.Options.OptionsMonitor`1[[Microsoft.Extensions.Logging.LoggerFilterOptions, Microsoft.Extensions.Logging]]
            ->  00007FBB342330C8 Microsoft.Extensions.Options.OptionsFactory`1[[Microsoft.Extensions.Logging.LoggerFilterOptions, Microsoft.Extensions.Logging]]
            ->  00007FBB34232FD8 Microsoft.Extensions.Options.IConfigureOptions`1[[Microsoft.Extensions.Logging.LoggerFilterOptions, Microsoft.Extensions.Logging]][]
            ->  00007FBB34233008 Microsoft.Extensions.Logging.EventLogFiltersConfigureOptions
            ->  00007FBB3403D050 Microsoft.Extensions.Logging.EventSource.LoggingEventSource
            ->  00007FBB342B2BC8 System.Diagnostics.Tracing.EventDispatcher
            ->  00007FBB342647D8 App.Metrics.Extensions.Collectors.EventListeners.GcEventListener
            ->  00007FBB341FE680 App.Metrics.MetricsRoot
            ->  00007FBB341FE638 App.Metrics.Internal.DefaultMetrics
            ->  00007FBB341FE620 App.Metrics.Internal.DefaultMetricsManager
            ->  00007FBB341FC378 App.Metrics.Internal.DefaultMetricsRegistry
            ->  00007FBB341FC3B0 System.Collections.Concurrent.ConcurrentDictionary`2[[System.String, System.Private.CoreLib],[App.Metrics.Registry.IMetricContextRegistry, App.Metrics.Abstractions]]
            ->  00007FBB341FC628 System.Collections.Concurrent.ConcurrentDictionary`2+Tables[[System.String, System.Private.CoreLib],[App.Metrics.Registry.IMetricContextRegistry, App.Metrics.Abstractions]]
            ->  00007FBB341FC518 System.Collections.Concurrent.ConcurrentDictionary`2+Node[[System.String, System.Private.CoreLib],[App.Metrics.Registry.IMetricContextRegistry, App.Metrics.Abstractions]][]
            ->  00007FBB3452C138 System.Collections.Concurrent.ConcurrentDictionary`2+Node[[System.String, System.Private.CoreLib],[App.Metrics.Registry.IMetricContextRegistry, App.Metrics.Abstractions]]
            ->  00007FBB3452A860 App.Metrics.Internal.DefaultMetricContextRegistry
            ->  00007FBB3452A8D0 App.Metrics.Internal.DefaultMetricContextRegistry+MetricMetaCatalog`3[[App.Metrics.Apdex.IApdex, App.Metrics.Abstractions],[App.Metrics.Apdex.ApdexValueSource, App.Metrics.Abstractions],[App.Metrics.Apdex.ApdexValue, App.Metrics.Abstractions]]
            ->  00007FBB3452A8E8 System.Collections.Concurrent.ConcurrentDictionary`2[[System.String, System.Private.CoreLib],[App.Metrics.Internal.DefaultMetricContextRegistry+MetricMetaCatalog`3+MetricMeta[[App.Metrics.Apdex.IApdex, App.Metrics.Abstractions],[App.Metrics.Apdex.ApdexValueSource, App.Metrics.Abstractions],[App.Metrics.Apdex.ApdexValue, App.Metrics.Abstractions]], App.Metrics.Core]]
            ->  00007FBB3452AB60 System.Collections.Concurrent.ConcurrentDictionary`2+Tables[[System.String, System.Private.CoreLib],[App.Metrics.Internal.DefaultMetricContextRegistry+MetricMetaCatalog`3+MetricMeta[[App.Metrics.Apdex.IApdex, App.Metrics.Abstractions],[App.Metrics.Apdex.ApdexValueSource, App.Metrics.Abstractions],[App.Metrics.Apdex.ApdexValue, App.Metrics.Abstractions]], App.Metrics.Core]]
            ->  00007FBB3452AA50 System.Collections.Concurrent.ConcurrentDictionary`2+Node[[System.String, System.Private.CoreLib],[App.Metrics.Internal.DefaultMetricContextRegistry+MetricMetaCatalog`3+MetricMeta[[App.Metrics.Apdex.IApdex, App.Metrics.Abstractions],[App.Metrics.Apdex.ApdexValueSource, App.Metrics.Abstractions],[App.Metrics.Apdex.ApdexValue, App.Metrics.Abstractions]], App.Metrics.Core]][]
            ->  00007FBB34535328 System.Collections.Concurrent.ConcurrentDictionary`2+Node[[System.String, System.Private.CoreLib],[App.Metrics.Internal.DefaultMetricContextRegistry+MetricMetaCatalog`3+MetricMeta[[App.Metrics.Apdex.IApdex, App.Metrics.Abstractions],[App.Metrics.Apdex.ApdexValueSource, App.Metrics.Abstractions],[App.Metrics.Apdex.ApdexValue, App.Metrics.Abstractions]], App.Metrics.Core]]
            ->  00007FBB34535308 App.Metrics.Internal.DefaultMetricContextRegistry+MetricMetaCatalog`3+MetricMeta[[App.Metrics.Apdex.IApdex, App.Metrics.Abstractions],[App.Metrics.Apdex.ApdexValueSource, App.Metrics.Abstractions],[App.Metrics.Apdex.ApdexValue, App.Metrics.Abstractions]]
            ->  00007FBB34535268 App.Metrics.Apdex.DefaultApdexMetric
            ->  00007FBB3452C3A0 App.Metrics.Apdex.ApdexProvider
            ->  00007FBB3452C3E8 App.Metrics.ReservoirSampling.ExponentialDecay.DefaultForwardDecayingReservoir
            ->  00007FBB34534C78 App.Metrics.Scheduling.DefaultReservoirRescaleScheduler
            ->  00007FBB34534DA8 App.Metrics.Internal.DefaultMetricsTaskSchedular
            ->  00007FBB34534E78 System.Threading.Timer
            ->  00007FBB34534EF0 System.Threading.TimerHolder
            ->  00007FBB34534E90 System.Threading.TimerQueueTimer
            ->  00007FBB3406B0F0 System.Threading.TimerQueue
            ->  00007FBB35643EA8 System.Threading.TimerQueueTimer
            ->  00007FBB3B2E2E08 System.Threading.TimerQueueTimer
            ->  00007FBB3B2D2AA0 System.Threading.TimerQueueTimer
            ->  00007FBB3B2C2738 System.Threading.TimerQueueTimer
            ->  00007FBB3450DC28 System.Threading.TimerQueueTimer
            ->  00007FBB341D2120 System.Threading.TimerQueueTimer
            ->  00007FBB347B9D10 System.Threading.TimerQueueTimer
            ->  00007FBB39D3FAB8 System.Threading.TimerQueueTimer
            ->  00007FBB3934F990 System.Threading.TimerQueueTimer
            ->  00007FBB3934F8D0 System.Threading.TimerQueueTimer
            ->  00007FBB3450B410 System.Threading.TimerQueueTimer
            ->  00007FBB39D41CB0 System.Threading.TimerQueueTimer
            ->  00007FBB39D41C30 Microsoft.Extensions.Http.ActiveHandlerTrackingEntry
            ->  00007FBB34630870 System.Threading.TimerCallback
            ->  00007FBB3462FE20 Microsoft.Extensions.Http.DefaultHttpClientFactory
            ->  00007FBB342148E8 Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope
            ->  00007FBB3421FAF8 System.Collections.Generic.List`1[[System.Object, System.Private.CoreLib]]
            ->  00007FBB342517D8 System.Object[]
            ->  00007FBB34236EB0 Microsoft.Extensions.Hosting.Internal.ConsoleLifetime
            ->  00007FBB34236258 Microsoft.Extensions.Hosting.Internal.ApplicationLifetime
            ->  00007FBB342362C8 System.Threading.CancellationTokenSource
            ->  00007FBB342374B8 System.Threading.CancellationTokenSource+CallbackPartition[]
            ->  00007FBB34237510 System.Threading.CancellationTokenSource+CallbackPartition
            ->  00007FBB34237548 System.Threading.CancellationTokenSource+CallbackNode
            ->  00007FBB34515CD0 System.Threading.CancellationTokenSource+CallbackNode
            ->  00007FBB342B5C08 System.Threading.CancellationTokenSource+CallbackNode
            ->  00007FBB342B5BC8 System.Action
            ->  00007FBB342B5B88 Presentation.Api.Startup+<>c__DisplayClass5_0
            ->  00007FBB342B32B8 Microsoft.AspNetCore.Builder.ApplicationBuilder
            ->  00007FBB342B3350 System.Collections.Generic.List`1[[System.Func`2[[Microsoft.AspNetCore.Http.RequestDelegate, Microsoft.AspNetCore.Http.Abstractions],[Microsoft.AspNetCore.Http.RequestDelegate, Microsoft.AspNetCore.Http.Abstractions]], System.Private.CoreLib]]
            ->  00007FBB343261E8 System.Func`2[[Microsoft.AspNetCore.Http.RequestDelegate, Microsoft.AspNetCore.Http.Abstractions],[Microsoft.AspNetCore.Http.RequestDelegate, Microsoft.AspNetCore.Http.Abstractions]][]
            ->  00007FBB3431BA18 System.Func`2[[Microsoft.AspNetCore.Http.RequestDelegate, Microsoft.AspNetCore.Http.Abstractions],[Microsoft.AspNetCore.Http.RequestDelegate, Microsoft.AspNetCore.Http.Abstractions]]
            ->  00007FBB3431B898 Microsoft.AspNetCore.Builder.UseWhenExtensions+<>c__DisplayClass0_0
            ->  00007FBB3431B8E0 Microsoft.AspNetCore.Builder.ApplicationBuilder
            ->  00007FBB3431B900 System.Collections.Generic.List`1[[System.Func`2[[Microsoft.AspNetCore.Http.RequestDelegate, Microsoft.AspNetCore.Http.Abstractions],[Microsoft.AspNetCore.Http.RequestDelegate, Microsoft.AspNetCore.Http.Abstractions]], System.Private.CoreLib]]
            ->  00007FBB3431B9E0 System.Func`2[[Microsoft.AspNetCore.Http.RequestDelegate, Microsoft.AspNetCore.Http.Abstractions],[Microsoft.AspNetCore.Http.RequestDelegate, Microsoft.AspNetCore.Http.Abstractions]][]
            ->  00007FBB34543E40 System.Func`2[[Microsoft.AspNetCore.Http.RequestDelegate, Microsoft.AspNetCore.Http.Abstractions],[Microsoft.AspNetCore.Http.RequestDelegate, Microsoft.AspNetCore.Http.Abstractions]]
            ->  00007FBB34543E28 Microsoft.AspNetCore.Builder.RunExtensions+<>c__DisplayClass0_0
            ->  00007FBB34543DC0 Microsoft.AspNetCore.Http.RequestDelegate
            ->  00007FBB345435E0 Microsoft.AspNetCore.Builder.UseWhenExtensions+<>c__DisplayClass0_1
            ->  00007FBB34543D80 Microsoft.AspNetCore.Http.RequestDelegate
            ->  00007FBB34543D48 App.Metrics.AspNetCore.Tracking.Middleware.ErrorRequestMeterMiddleware
            ->  00007FBB345435A0 Microsoft.AspNetCore.Http.RequestDelegate
            ->  00007FBB34542DA0 Microsoft.AspNetCore.Builder.UseWhenExtensions+<>c__DisplayClass0_1
            ->  00007FBB34543560 Microsoft.AspNetCore.Http.RequestDelegate
            ->  00007FBB34543520 App.Metrics.AspNetCore.Tracking.Middleware.PostAndPutRequestSizeHistogramMiddleware
            ->  00007FBB34542D60 Microsoft.AspNetCore.Http.RequestDelegate
            ->  00007FBB34536420 Microsoft.AspNetCore.Builder.UseWhenExtensions+<>c__DisplayClass0_1
            ->  00007FBB34542D20 Microsoft.AspNetCore.Http.RequestDelegate
            ->  00007FBB34536B78 App.Metrics.AspNetCore.Tracking.Middleware.RequestTimerMiddleware
            ->  00007FBB345363E0 Microsoft.AspNetCore.Http.RequestDelegate
            ->  00007FBB34535C00 Microsoft.AspNetCore.Builder.UseWhenExtensions+<>c__DisplayClass0_1
            ->  00007FBB345363A0 Microsoft.AspNetCore.Http.RequestDelegate
            ->  00007FBB34536360 App.Metrics.AspNetCore.Tracking.Middleware.PerRequestTimerMiddleware
            ->  00007FBB34535BC0 Microsoft.AspNetCore.Http.RequestDelegate
            ->  00007FBB345353D8 Microsoft.AspNetCore.Builder.UseWhenExtensions+<>c__DisplayClass0_1
            ->  00007FBB34535B80 Microsoft.AspNetCore.Http.RequestDelegate
            ->  00007FBB34535B38 App.Metrics.AspNetCore.Tracking.Middleware.OAuthTrackingMiddleware
            ->  00007FBB34535398 Microsoft.AspNetCore.Http.RequestDelegate
            ->  00007FBB34529EC0 Microsoft.AspNetCore.Builder.UseWhenExtensions+<>c__DisplayClass0_1
            ->  00007FBB34535358 Microsoft.AspNetCore.Http.RequestDelegate
            ->  00007FBB3452A610 App.Metrics.AspNetCore.Tracking.Middleware.ApdexMiddleware
            ->  00007FBB34529E80 Microsoft.AspNetCore.Http.RequestDelegate
            ->  00007FBB34529E68 Common.Helper.ASPNetCore.ExceptionMiddleware.GlobalExceptionMiddleware
            ->  00007FBB34529E28 Microsoft.AspNetCore.Http.RequestDelegate
            ->  00007FBB34529558 Microsoft.AspNetCore.HttpOverrides.ForwardedHeadersMiddleware
            ->  00007FBB34528380 Microsoft.AspNetCore.Http.RequestDelegate
            ->  00007FBB34527F10 Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware
            ->  00007FBB34526DD0 Microsoft.AspNetCore.Http.RequestDelegate
            ->  00007FBB3451CB00 Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware
            ->  00007FBB3451B9D8 Microsoft.AspNetCore.Http.RequestDelegate
            ->  00007FBB3451A810 Microsoft.AspNetCore.CookiePolicy.CookiePolicyMiddleware
            ->  00007FBB34519750 Microsoft.AspNetCore.Http.RequestDelegate
            ->  00007FBB34519650 Microsoft.AspNetCore.Builder.UseWhenExtensions+<>c__DisplayClass0_1
            ->  00007FBB34519610 Microsoft.AspNetCore.Http.RequestDelegate
            ->  00007FBB345194E8 Microsoft.AspNetCore.Builder.UseWhenExtensions+<>c__DisplayClass0_1
            ->  00007FBB345194A8 Microsoft.AspNetCore.Http.RequestDelegate
            ->  00007FBB34518CB0 Microsoft.AspNetCore.Builder.UseWhenExtensions+<>c__DisplayClass0_1
            ->  00007FBB34518C70 Microsoft.AspNetCore.Http.RequestDelegate
            ->  00007FBB345181D0 Microsoft.AspNetCore.Builder.UseWhenExtensions+<>c__DisplayClass0_1
            ->  00007FBB34518190 Microsoft.AspNetCore.Http.RequestDelegate
            ->  00007FBB34518048 Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware
            ->  00007FBB34518088 Microsoft.AspNetCore.Routing.CompositeEndpointDataSource
            ->  00007FBB34518138 System.Collections.Generic.List`1[[Microsoft.AspNetCore.Routing.EndpointDataSource, Microsoft.AspNetCore.Routing]]
            ->  00007FBB34518158 Microsoft.AspNetCore.Routing.EndpointDataSource[]
            ->  00007FBB3438A780 Microsoft.AspNetCore.Mvc.Routing.ControllerActionEndpointDataSource
            ->  00007FBB34571DB8 System.Collections.Generic.List`1[[Microsoft.AspNetCore.Http.Endpoint, Microsoft.AspNetCore.Http.Abstractions]]
            ->  00007FBB34599D10 Microsoft.AspNetCore.Http.Endpoint[]
            ->  00007FBB34573008 Microsoft.AspNetCore.Routing.RouteEndpoint
            ->  00007FBB3438A6D0 Microsoft.AspNetCore.Http.RequestDelegate
            ->  00007FBB3438A6B8 Microsoft.AspNetCore.Mvc.Routing.ActionEndpointFactory+<>c__DisplayClass7_0
            ->  00007FBB34608738 Microsoft.AspNetCore.Mvc.Infrastructure.ActionInvokerFactory
            ->  00007FBB346087A8 Microsoft.AspNetCore.Mvc.Abstractions.IActionInvokerProvider[]
            ->  00007FBB34606C50 Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvokerProvider
            ->  00007FBB34606B70 Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvokerCache
            ->  00007FBB34608848 Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvokerCache+InnerCache
            ->  00007FBB34608868 System.Collections.Concurrent.ConcurrentDictionary`2[[Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor, Microsoft.AspNetCore.Mvc.Abstractions],[Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvokerCacheEntry, Microsoft.AspNetCore.Mvc.Core]]
            ->  00007FBB35F2E8E8 System.Collections.Concurrent.ConcurrentDictionary`2+Tables[[Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor, Microsoft.AspNetCore.Mvc.Abstractions],[Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvokerCacheEntry, Microsoft.AspNetCore.Mvc.Core]]
            ->  00007FBB35F2DF10 System.Collections.Concurrent.ConcurrentDictionary`2+Node[[Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor, Microsoft.AspNetCore.Mvc.Abstractions],[Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvokerCacheEntry, Microsoft.AspNetCore.Mvc.Core]][]
            ->  00007FBB35F2EC48 System.Collections.Concurrent.ConcurrentDictionary`2+Node[[Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor, Microsoft.AspNetCore.Mvc.Abstractions],[Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvokerCacheEntry, Microsoft.AspNetCore.Mvc.Core]]
            ->  00007FBB3510EDB0 Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvokerCacheEntry
            ->  00007FBB35104B78 Microsoft.Extensions.Internal.ObjectMethodExecutor
            ->  00007FBB3510DEF0 Microsoft.Extensions.Internal.ObjectMethodExecutor+MethodExecutorAsync
            ->  00007FBB3510DD58 System.Runtime.CompilerServices.Closure
            ->  00007FBB3510DD78 System.Object[]
            ->  00007FBB3510CCA8 System.Func`2[[System.Object, System.Private.CoreLib],[System.Object, System.Private.CoreLib]]

Found 1 unique roots (run 'gcroot -all' to see all roots).

who can help me analyze the cause of that the small object(about 40btye) not released in gen0. thanks in advanced!

dotnet-issue-labeler[bot] commented 3 years ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

ZhiqiangTao commented 3 years ago

env:

  1. .net core 5.0 (5.0.200)
  2. in k8s docker
  3. gc mode : workstation gc
ghost commented 3 years ago

Tagging subscribers to this area: @dotnet/gc See info in area-owners.md if you want to be subscribed.

Issue Details
recently, I meet an issue ![image](https://user-images.githubusercontent.com/16182251/116949113-df469380-acb3-11eb-8868-95f273b6e7fd.png) as you can see, the gen2 is very large(about 120m) smaller than LOH, so I think there are many objects migrate from gen0 ->gen1-to gen2, then I use gcroot and gcwhere to inspect some objects , but i found that most of them are handled by below: ``` > gcwhere **00007fbb3510cca8** Address Gen Heap segment begin allocated size 00007FBB3510CCA8 **2** 0 00007FBB33FFE000 00007FBB33FFF000 00007FBB3B5402D0 0x40(64) > gcroot **00007fbb3510cca8** Thread 1: 00007FFD1E9D5C30 00007FBC8BE3F1D0 System.Threading.Tasks.Task.SpinThenBlockingWait(Int32, System.Threading.CancellationToken) rbp-30: 00007ffd1e9d5c50 -> 00007FBB3454B598 System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[System.Threading.Tasks.VoidTaskResult, System.Private.CoreLib],[Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions+d__4, Microsoft.Extensions.Hosting.Abstractions]] -> 00007FBB342373F0 Microsoft.Extensions.Hosting.Internal.Host -> 00007FBB34236360 Microsoft.Extensions.Logging.Logger`1[[Microsoft.Extensions.Hosting.Internal.Host, Microsoft.Extensions.Hosting]] -> 00007FBB34236480 Microsoft.Extensions.Logging.Logger -> 00007FBB342364A8 Microsoft.Extensions.Logging.LoggerInformation[] -> 00007FBB34236548 Microsoft.Extensions.Logging.Console.ConsoleLogger -> 00007FBB342309D8 Microsoft.Extensions.Logging.Console.SimpleConsoleFormatter -> 00007FBB34230BA8 Microsoft.Extensions.Options.OptionsMonitor`1+ChangeTrackerDisposable[[Microsoft.Extensions.Logging.Console.SimpleConsoleFormatterOptions, Microsoft.Extensions.Logging.Console]] -> 00007FBB34230810 Microsoft.Extensions.Options.OptionsMonitor`1[[Microsoft.Extensions.Logging.Console.SimpleConsoleFormatterOptions, Microsoft.Extensions.Logging.Console]] -> 00007FBB34230480 Microsoft.Extensions.Options.OptionsFactory`1[[Microsoft.Extensions.Logging.Console.SimpleConsoleFormatterOptions, Microsoft.Extensions.Logging.Console]] -> 00007FBB34230320 Microsoft.Extensions.Options.IConfigureOptions`1[[Microsoft.Extensions.Logging.Console.SimpleConsoleFormatterOptions, Microsoft.Extensions.Logging.Console]][] -> 00007FBB34230340 Microsoft.Extensions.Logging.ConsoleLoggerFormatterConfigureOptions`2[[Microsoft.Extensions.Logging.Console.SimpleConsoleFormatter, Microsoft.Extensions.Logging.Console],[Microsoft.Extensions.Logging.Console.SimpleConsoleFormatterOptions, Microsoft.Extensions.Logging.Console]] -> 00007FBB34230398 System.Action`1[[Microsoft.Extensions.Logging.Console.SimpleConsoleFormatterOptions, Microsoft.Extensions.Logging.Console]] -> 00007FBB34230380 Microsoft.Extensions.Options.ConfigureFromConfigurationOptions`1+<>c__DisplayClass0_0[[Microsoft.Extensions.Logging.Console.SimpleConsoleFormatterOptions, Microsoft.Extensions.Logging.Console]] -> 00007FBB34230358 Microsoft.Extensions.Configuration.ConfigurationSection -> 00007FBB3422C1D8 Microsoft.Extensions.Configuration.ConfigurationRoot -> 00007FBB3422C140 System.Collections.Generic.List`1[[Microsoft.Extensions.Configuration.IConfigurationProvider, Microsoft.Extensions.Configuration.Abstractions]] -> 00007FBB3422C180 Microsoft.Extensions.Configuration.IConfigurationProvider[] -> 00007FBB3422C160 Microsoft.Extensions.Configuration.ChainedConfigurationProvider -> 00007FBB3422C078 Microsoft.Extensions.Configuration.ConfigurationSection -> 00007FBB34029FC8 Microsoft.Extensions.Configuration.ConfigurationRoot -> 00007FBB34029FF0 Microsoft.Extensions.Configuration.ConfigurationReloadToken -> 00007FBB3402A008 System.Threading.CancellationTokenSource -> 00007FBB3422C368 System.Threading.CancellationTokenSource+CallbackPartition[] -> 00007FBB3422C3C0 System.Threading.CancellationTokenSource+CallbackPartition -> 00007FBB3454AD40 System.Threading.CancellationTokenSource+CallbackNode -> 00007FBB34546E08 System.Threading.CancellationTokenSource+CallbackNode -> 00007FBB342335E8 System.Threading.CancellationTokenSource+CallbackNode -> 00007FBB34233570 Microsoft.Extensions.Primitives.ChangeToken+ChangeTokenRegistration`1[[System.String, System.Private.CoreLib]] -> 00007FBB342334E8 System.Action`1[[System.String, System.Private.CoreLib]] -> 00007FBB34233438 Microsoft.Extensions.Options.OptionsMonitor`1[[Microsoft.Extensions.Logging.LoggerFilterOptions, Microsoft.Extensions.Logging]] -> 00007FBB342330C8 Microsoft.Extensions.Options.OptionsFactory`1[[Microsoft.Extensions.Logging.LoggerFilterOptions, Microsoft.Extensions.Logging]] -> 00007FBB34232FD8 Microsoft.Extensions.Options.IConfigureOptions`1[[Microsoft.Extensions.Logging.LoggerFilterOptions, Microsoft.Extensions.Logging]][] -> 00007FBB34233008 Microsoft.Extensions.Logging.EventLogFiltersConfigureOptions -> 00007FBB3403D050 Microsoft.Extensions.Logging.EventSource.LoggingEventSource -> 00007FBB342B2BC8 System.Diagnostics.Tracing.EventDispatcher -> 00007FBB342647D8 App.Metrics.Extensions.Collectors.EventListeners.GcEventListener -> 00007FBB341FE680 App.Metrics.MetricsRoot -> 00007FBB341FE638 App.Metrics.Internal.DefaultMetrics -> 00007FBB341FE620 App.Metrics.Internal.DefaultMetricsManager -> 00007FBB341FC378 App.Metrics.Internal.DefaultMetricsRegistry -> 00007FBB341FC3B0 System.Collections.Concurrent.ConcurrentDictionary`2[[System.String, System.Private.CoreLib],[App.Metrics.Registry.IMetricContextRegistry, App.Metrics.Abstractions]] -> 00007FBB341FC628 System.Collections.Concurrent.ConcurrentDictionary`2+Tables[[System.String, System.Private.CoreLib],[App.Metrics.Registry.IMetricContextRegistry, App.Metrics.Abstractions]] -> 00007FBB341FC518 System.Collections.Concurrent.ConcurrentDictionary`2+Node[[System.String, System.Private.CoreLib],[App.Metrics.Registry.IMetricContextRegistry, App.Metrics.Abstractions]][] -> 00007FBB3452C138 System.Collections.Concurrent.ConcurrentDictionary`2+Node[[System.String, System.Private.CoreLib],[App.Metrics.Registry.IMetricContextRegistry, App.Metrics.Abstractions]] -> 00007FBB3452A860 App.Metrics.Internal.DefaultMetricContextRegistry -> 00007FBB3452A8D0 App.Metrics.Internal.DefaultMetricContextRegistry+MetricMetaCatalog`3[[App.Metrics.Apdex.IApdex, App.Metrics.Abstractions],[App.Metrics.Apdex.ApdexValueSource, App.Metrics.Abstractions],[App.Metrics.Apdex.ApdexValue, App.Metrics.Abstractions]] -> 00007FBB3452A8E8 System.Collections.Concurrent.ConcurrentDictionary`2[[System.String, System.Private.CoreLib],[App.Metrics.Internal.DefaultMetricContextRegistry+MetricMetaCatalog`3+MetricMeta[[App.Metrics.Apdex.IApdex, App.Metrics.Abstractions],[App.Metrics.Apdex.ApdexValueSource, App.Metrics.Abstractions],[App.Metrics.Apdex.ApdexValue, App.Metrics.Abstractions]], App.Metrics.Core]] -> 00007FBB3452AB60 System.Collections.Concurrent.ConcurrentDictionary`2+Tables[[System.String, System.Private.CoreLib],[App.Metrics.Internal.DefaultMetricContextRegistry+MetricMetaCatalog`3+MetricMeta[[App.Metrics.Apdex.IApdex, App.Metrics.Abstractions],[App.Metrics.Apdex.ApdexValueSource, App.Metrics.Abstractions],[App.Metrics.Apdex.ApdexValue, App.Metrics.Abstractions]], App.Metrics.Core]] -> 00007FBB3452AA50 System.Collections.Concurrent.ConcurrentDictionary`2+Node[[System.String, System.Private.CoreLib],[App.Metrics.Internal.DefaultMetricContextRegistry+MetricMetaCatalog`3+MetricMeta[[App.Metrics.Apdex.IApdex, App.Metrics.Abstractions],[App.Metrics.Apdex.ApdexValueSource, App.Metrics.Abstractions],[App.Metrics.Apdex.ApdexValue, App.Metrics.Abstractions]], App.Metrics.Core]][] -> 00007FBB34535328 System.Collections.Concurrent.ConcurrentDictionary`2+Node[[System.String, System.Private.CoreLib],[App.Metrics.Internal.DefaultMetricContextRegistry+MetricMetaCatalog`3+MetricMeta[[App.Metrics.Apdex.IApdex, App.Metrics.Abstractions],[App.Metrics.Apdex.ApdexValueSource, App.Metrics.Abstractions],[App.Metrics.Apdex.ApdexValue, App.Metrics.Abstractions]], App.Metrics.Core]] -> 00007FBB34535308 App.Metrics.Internal.DefaultMetricContextRegistry+MetricMetaCatalog`3+MetricMeta[[App.Metrics.Apdex.IApdex, App.Metrics.Abstractions],[App.Metrics.Apdex.ApdexValueSource, App.Metrics.Abstractions],[App.Metrics.Apdex.ApdexValue, App.Metrics.Abstractions]] -> 00007FBB34535268 App.Metrics.Apdex.DefaultApdexMetric -> 00007FBB3452C3A0 App.Metrics.Apdex.ApdexProvider -> 00007FBB3452C3E8 App.Metrics.ReservoirSampling.ExponentialDecay.DefaultForwardDecayingReservoir -> 00007FBB34534C78 App.Metrics.Scheduling.DefaultReservoirRescaleScheduler -> 00007FBB34534DA8 App.Metrics.Internal.DefaultMetricsTaskSchedular -> 00007FBB34534E78 System.Threading.Timer -> 00007FBB34534EF0 System.Threading.TimerHolder -> 00007FBB34534E90 System.Threading.TimerQueueTimer -> 00007FBB3406B0F0 System.Threading.TimerQueue -> 00007FBB35643EA8 System.Threading.TimerQueueTimer -> 00007FBB3B2E2E08 System.Threading.TimerQueueTimer -> 00007FBB3B2D2AA0 System.Threading.TimerQueueTimer -> 00007FBB3B2C2738 System.Threading.TimerQueueTimer -> 00007FBB3450DC28 System.Threading.TimerQueueTimer -> 00007FBB341D2120 System.Threading.TimerQueueTimer -> 00007FBB347B9D10 System.Threading.TimerQueueTimer -> 00007FBB39D3FAB8 System.Threading.TimerQueueTimer -> 00007FBB3934F990 System.Threading.TimerQueueTimer -> 00007FBB3934F8D0 System.Threading.TimerQueueTimer -> 00007FBB3450B410 System.Threading.TimerQueueTimer -> 00007FBB39D41CB0 System.Threading.TimerQueueTimer -> 00007FBB39D41C30 Microsoft.Extensions.Http.ActiveHandlerTrackingEntry -> 00007FBB34630870 System.Threading.TimerCallback -> 00007FBB3462FE20 Microsoft.Extensions.Http.DefaultHttpClientFactory -> 00007FBB342148E8 Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope -> 00007FBB3421FAF8 System.Collections.Generic.List`1[[System.Object, System.Private.CoreLib]] -> 00007FBB342517D8 System.Object[] -> 00007FBB34236EB0 Microsoft.Extensions.Hosting.Internal.ConsoleLifetime -> 00007FBB34236258 Microsoft.Extensions.Hosting.Internal.ApplicationLifetime -> 00007FBB342362C8 System.Threading.CancellationTokenSource -> 00007FBB342374B8 System.Threading.CancellationTokenSource+CallbackPartition[] -> 00007FBB34237510 System.Threading.CancellationTokenSource+CallbackPartition -> 00007FBB34237548 System.Threading.CancellationTokenSource+CallbackNode -> 00007FBB34515CD0 System.Threading.CancellationTokenSource+CallbackNode -> 00007FBB342B5C08 System.Threading.CancellationTokenSource+CallbackNode -> 00007FBB342B5BC8 System.Action -> 00007FBB342B5B88 Presentation.Api.Startup+<>c__DisplayClass5_0 -> 00007FBB342B32B8 Microsoft.AspNetCore.Builder.ApplicationBuilder -> 00007FBB342B3350 System.Collections.Generic.List`1[[System.Func`2[[Microsoft.AspNetCore.Http.RequestDelegate, Microsoft.AspNetCore.Http.Abstractions],[Microsoft.AspNetCore.Http.RequestDelegate, Microsoft.AspNetCore.Http.Abstractions]], System.Private.CoreLib]] -> 00007FBB343261E8 System.Func`2[[Microsoft.AspNetCore.Http.RequestDelegate, Microsoft.AspNetCore.Http.Abstractions],[Microsoft.AspNetCore.Http.RequestDelegate, Microsoft.AspNetCore.Http.Abstractions]][] -> 00007FBB3431BA18 System.Func`2[[Microsoft.AspNetCore.Http.RequestDelegate, Microsoft.AspNetCore.Http.Abstractions],[Microsoft.AspNetCore.Http.RequestDelegate, Microsoft.AspNetCore.Http.Abstractions]] -> 00007FBB3431B898 Microsoft.AspNetCore.Builder.UseWhenExtensions+<>c__DisplayClass0_0 -> 00007FBB3431B8E0 Microsoft.AspNetCore.Builder.ApplicationBuilder -> 00007FBB3431B900 System.Collections.Generic.List`1[[System.Func`2[[Microsoft.AspNetCore.Http.RequestDelegate, Microsoft.AspNetCore.Http.Abstractions],[Microsoft.AspNetCore.Http.RequestDelegate, Microsoft.AspNetCore.Http.Abstractions]], System.Private.CoreLib]] -> 00007FBB3431B9E0 System.Func`2[[Microsoft.AspNetCore.Http.RequestDelegate, Microsoft.AspNetCore.Http.Abstractions],[Microsoft.AspNetCore.Http.RequestDelegate, Microsoft.AspNetCore.Http.Abstractions]][] -> 00007FBB34543E40 System.Func`2[[Microsoft.AspNetCore.Http.RequestDelegate, Microsoft.AspNetCore.Http.Abstractions],[Microsoft.AspNetCore.Http.RequestDelegate, Microsoft.AspNetCore.Http.Abstractions]] -> 00007FBB34543E28 Microsoft.AspNetCore.Builder.RunExtensions+<>c__DisplayClass0_0 -> 00007FBB34543DC0 Microsoft.AspNetCore.Http.RequestDelegate -> 00007FBB345435E0 Microsoft.AspNetCore.Builder.UseWhenExtensions+<>c__DisplayClass0_1 -> 00007FBB34543D80 Microsoft.AspNetCore.Http.RequestDelegate -> 00007FBB34543D48 App.Metrics.AspNetCore.Tracking.Middleware.ErrorRequestMeterMiddleware -> 00007FBB345435A0 Microsoft.AspNetCore.Http.RequestDelegate -> 00007FBB34542DA0 Microsoft.AspNetCore.Builder.UseWhenExtensions+<>c__DisplayClass0_1 -> 00007FBB34543560 Microsoft.AspNetCore.Http.RequestDelegate -> 00007FBB34543520 App.Metrics.AspNetCore.Tracking.Middleware.PostAndPutRequestSizeHistogramMiddleware -> 00007FBB34542D60 Microsoft.AspNetCore.Http.RequestDelegate -> 00007FBB34536420 Microsoft.AspNetCore.Builder.UseWhenExtensions+<>c__DisplayClass0_1 -> 00007FBB34542D20 Microsoft.AspNetCore.Http.RequestDelegate -> 00007FBB34536B78 App.Metrics.AspNetCore.Tracking.Middleware.RequestTimerMiddleware -> 00007FBB345363E0 Microsoft.AspNetCore.Http.RequestDelegate -> 00007FBB34535C00 Microsoft.AspNetCore.Builder.UseWhenExtensions+<>c__DisplayClass0_1 -> 00007FBB345363A0 Microsoft.AspNetCore.Http.RequestDelegate -> 00007FBB34536360 App.Metrics.AspNetCore.Tracking.Middleware.PerRequestTimerMiddleware -> 00007FBB34535BC0 Microsoft.AspNetCore.Http.RequestDelegate -> 00007FBB345353D8 Microsoft.AspNetCore.Builder.UseWhenExtensions+<>c__DisplayClass0_1 -> 00007FBB34535B80 Microsoft.AspNetCore.Http.RequestDelegate -> 00007FBB34535B38 App.Metrics.AspNetCore.Tracking.Middleware.OAuthTrackingMiddleware -> 00007FBB34535398 Microsoft.AspNetCore.Http.RequestDelegate -> 00007FBB34529EC0 Microsoft.AspNetCore.Builder.UseWhenExtensions+<>c__DisplayClass0_1 -> 00007FBB34535358 Microsoft.AspNetCore.Http.RequestDelegate -> 00007FBB3452A610 App.Metrics.AspNetCore.Tracking.Middleware.ApdexMiddleware -> 00007FBB34529E80 Microsoft.AspNetCore.Http.RequestDelegate -> 00007FBB34529E68 Common.Helper.ASPNetCore.ExceptionMiddleware.GlobalExceptionMiddleware -> 00007FBB34529E28 Microsoft.AspNetCore.Http.RequestDelegate -> 00007FBB34529558 Microsoft.AspNetCore.HttpOverrides.ForwardedHeadersMiddleware -> 00007FBB34528380 Microsoft.AspNetCore.Http.RequestDelegate -> 00007FBB34527F10 Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware -> 00007FBB34526DD0 Microsoft.AspNetCore.Http.RequestDelegate -> 00007FBB3451CB00 Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware -> 00007FBB3451B9D8 Microsoft.AspNetCore.Http.RequestDelegate -> 00007FBB3451A810 Microsoft.AspNetCore.CookiePolicy.CookiePolicyMiddleware -> 00007FBB34519750 Microsoft.AspNetCore.Http.RequestDelegate -> 00007FBB34519650 Microsoft.AspNetCore.Builder.UseWhenExtensions+<>c__DisplayClass0_1 -> 00007FBB34519610 Microsoft.AspNetCore.Http.RequestDelegate -> 00007FBB345194E8 Microsoft.AspNetCore.Builder.UseWhenExtensions+<>c__DisplayClass0_1 -> 00007FBB345194A8 Microsoft.AspNetCore.Http.RequestDelegate -> 00007FBB34518CB0 Microsoft.AspNetCore.Builder.UseWhenExtensions+<>c__DisplayClass0_1 -> 00007FBB34518C70 Microsoft.AspNetCore.Http.RequestDelegate -> 00007FBB345181D0 Microsoft.AspNetCore.Builder.UseWhenExtensions+<>c__DisplayClass0_1 -> 00007FBB34518190 Microsoft.AspNetCore.Http.RequestDelegate -> 00007FBB34518048 Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware -> 00007FBB34518088 Microsoft.AspNetCore.Routing.CompositeEndpointDataSource -> 00007FBB34518138 System.Collections.Generic.List`1[[Microsoft.AspNetCore.Routing.EndpointDataSource, Microsoft.AspNetCore.Routing]] -> 00007FBB34518158 Microsoft.AspNetCore.Routing.EndpointDataSource[] -> 00007FBB3438A780 Microsoft.AspNetCore.Mvc.Routing.ControllerActionEndpointDataSource -> 00007FBB34571DB8 System.Collections.Generic.List`1[[Microsoft.AspNetCore.Http.Endpoint, Microsoft.AspNetCore.Http.Abstractions]] -> 00007FBB34599D10 Microsoft.AspNetCore.Http.Endpoint[] -> 00007FBB34573008 Microsoft.AspNetCore.Routing.RouteEndpoint -> 00007FBB3438A6D0 Microsoft.AspNetCore.Http.RequestDelegate -> 00007FBB3438A6B8 Microsoft.AspNetCore.Mvc.Routing.ActionEndpointFactory+<>c__DisplayClass7_0 -> 00007FBB34608738 Microsoft.AspNetCore.Mvc.Infrastructure.ActionInvokerFactory -> 00007FBB346087A8 Microsoft.AspNetCore.Mvc.Abstractions.IActionInvokerProvider[] -> 00007FBB34606C50 Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvokerProvider -> 00007FBB34606B70 Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvokerCache -> 00007FBB34608848 Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvokerCache+InnerCache -> 00007FBB34608868 System.Collections.Concurrent.ConcurrentDictionary`2[[Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor, Microsoft.AspNetCore.Mvc.Abstractions],[Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvokerCacheEntry, Microsoft.AspNetCore.Mvc.Core]] -> 00007FBB35F2E8E8 System.Collections.Concurrent.ConcurrentDictionary`2+Tables[[Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor, Microsoft.AspNetCore.Mvc.Abstractions],[Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvokerCacheEntry, Microsoft.AspNetCore.Mvc.Core]] -> 00007FBB35F2DF10 System.Collections.Concurrent.ConcurrentDictionary`2+Node[[Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor, Microsoft.AspNetCore.Mvc.Abstractions],[Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvokerCacheEntry, Microsoft.AspNetCore.Mvc.Core]][] -> 00007FBB35F2EC48 System.Collections.Concurrent.ConcurrentDictionary`2+Node[[Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor, Microsoft.AspNetCore.Mvc.Abstractions],[Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvokerCacheEntry, Microsoft.AspNetCore.Mvc.Core]] -> 00007FBB3510EDB0 Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvokerCacheEntry -> 00007FBB35104B78 Microsoft.Extensions.Internal.ObjectMethodExecutor -> 00007FBB3510DEF0 Microsoft.Extensions.Internal.ObjectMethodExecutor+MethodExecutorAsync -> 00007FBB3510DD58 System.Runtime.CompilerServices.Closure -> 00007FBB3510DD78 System.Object[] -> 00007FBB3510CCA8 System.Func`2[[System.Object, System.Private.CoreLib],[System.Object, System.Private.CoreLib]] Found 1 unique roots (run 'gcroot -all' to see all roots). ``` who can help me analyze the cause of that the small object(about 40btye) not released in gen0. thanks in advanced!
Author: ZhiqiangTao
Assignees: -
Labels: `area-GC-coreclr`, `untriaged`
Milestone: -
mangod9 commented 3 years ago

are all the objects of type System.Func2[[System.Object, System.Private.CoreLib],[System.Object, System.Private.CoreLib]]? Have you tried using dumpheap to check what all objects are alive?

sharwell commented 3 years ago

I highly recommend PerfView for this analysis. It does a much better job than !gcroot at showing the shortest weighted path to root.

ZhiqiangTao commented 3 years ago

reference to :https://github.com/dotnet/efcore/issues/24841

acaly commented 3 years ago

It's probably impossible for someone else to figure it out for you without the source code. The reference tree generated by those tools will contain mostly unrelated info and useful items needs to be digged out.

Since there is a lot of Func, do you use lambda in your code? C# compiler is known to generate code that leads to potential memory leaks if you keep closures alive. Specifically, if you create 2 closures in a same block, they will usually hold unnecessary references to objects that are used only in each other's body. So if you keep one of them alive and something used in either one of them (or both) won't be collected.

davidfowl commented 3 years ago

The code here is part of MVC'a code base. It's the cache that stores thunks for invoking action methods.

ZhiqiangTao commented 3 years ago

mycode sample just like below: image image image any fault in there? Could you help me point out what's the problem :) @davidfowl @acaly

davidfowl commented 3 years ago

I'm not sure the above has anything to do with your code. How many controller actions do you have?

acaly commented 3 years ago

@ZhiqiangTao The second image shows a closure created capturing a variable. The other two don't create closure but the returned task will hold reference to the closure. To trigger the C# bug I mentioned, you need to:

The first one you probably need to check every single methods of your project. For the second, MVC framework shouldn't be storing anything permanently if you follow the scoped service pattern. It may happen if you created something yourself or store something (e.g., a Task for an async method that captures a closure variable) to static fields.