一、前言
前段时间更新发布了dotnetty,内存泄漏问题得到了修复,而后分析dump发现,还有Roslyn动态编译缓存数据没有得到回收,通过统计有5mb左右,这个占比可是整个项目的1/10,
然后通过分析是静态缓存数据,没有扩展方法可以清理,所以求助了Roslyn 社区,他们也非常热心,有一个中国的朋友点醒我用AssemblyLoadContext 卸载就能把缓存数据清空,谈到AssemblyLoadContext 卸载,用这个功能碰到问题,还是我提出的呢!以下是问题链接:
https://github.com/dotnet/runtime/issues/12143
https://github.com/dotnet/roslyn/issues/79624
那么此篇文章的目的就是如何通过AssemblyLoadContext卸载清空Roslyn动态编译缓存数据
HttpFlv:http://demo.kayakiot.cn:281/httpflv.html (黑衣人)
HttpFlv:http://demo.kayakiot.cn:281/httpflv1.html (大红包)
HttpFlv:http://demo.kayakiot.cn:281/httpflv2.html (鹿鼎记)
rtmp:rtmp://demo.kayakiot.cn:76/live1/livestream2 (黑衣人)
rtmp:rtmp://demo.kayakiot.cn:76/live1/livestream3 (大红包)
rtmp:rtmp://demo.kayakiot.cn:76/live1/livestream4(鹿鼎记)
注:测试服务器带宽只有8MB, httpflv 缓冲做的没有rtmp好,然后httpflv卡就多刷新几次
凯亚 (Kayak) 是什么?
凯亚(Kayak)是基于.NET8.0软件环境下的surging微服务引擎进行开发的, 平台包含了微服务和物联网平台。支持异步和响应式编程开发,功能包含了物模型,设备,产品,网络组件的统一管理和微服务平台下的注册中心,服务路由,模块,中间服务等管理。还有多协议适配(TCP,MQTT,UDP,CoAP,HTTP,Grpc,websocket,rtmp,httpflv,webservice,等),通过灵活多样的配置适配能够接入不同厂家不同协议等设备。并且通过设备告警,消息通知,数据可视化等功能。能够让你能快速建立起微服务物联网平台系统。
凯亚物联网平台:http://demo.kayakiot.cn:3100(用户名:fanly 密码:123456)
链路跟踪Skywalking V8:http://117.72.121.2:8080/
dotnetty:https://github.com/microsurging/DotNetty
surging 微服务引擎开源地址:https://github.com/fanliang11/surging(后面surging 会移动到microsurging进行维护)
二、dump分析
通过导出dump文件,先通过windbg进行分析,通过!dumpheap -stat分析结果如下
7ffe38030f18 211 10,128 System.Collections.Concurrent.ConcurrentDictionary<System.String, Microsoft.Extensions.Logging.Logger>+Node
7ffe374a9600 127 10,160 System.Collections.Generic.Dictionary<System.String, System.String>
7ffe3a3052c8 255 10,200 Jint.Parser.Location
7ffe37cf5108 233 10,264 Consul.KVPair[]
7ffe3943b308 75 10,312 Microsoft.CodeAnalysis.CSharp.Symbols.Metadata.PE.PENamedTypeSymbol[]
7ffe3995b010 118 10,320 Microsoft.CodeAnalysis.CSharp.PreciseAbstractFlowPass<Microsoft.CodeAnalysis.CSharp.ControlFlowPass+LocalState>+PendingBranch[]
7ffe385771a8 1 10,368 System.Collections.Generic.Dictionary<System.String, System.Collections.Generic.HashSet<Surging.Core.Consul.WatcherProvider.Watcher>>+Entry[]
7ffe38166448 118 10,384 Autofac.Core.Resolving.InstanceLookup
7ffe3897a080 3 10,408 System.Collections.Generic.Dictionary<NLog.LogFactory+LoggerCacheKey, System.WeakReference>+Entry[]
7ffe37575d60 218 10,464 System.Reflection.RuntimeAssembly
7ffe39500e40 99 10,504 Microsoft.CodeAnalysis.CSharp.BoundExpression[]
7ffe38a59b00 33 10,560 System.Collections.Concurrent.ConcurrentDictionary<System.String, System.Object>+VolatileNode[]
7ffe373cdcb0 191 10,696 Autofac.Builder.SingleRegistrationStyle
7ffe38056e38 2 10,848 System.Collections.Concurrent.ConcurrentDictionary<System.Guid, System.Object>+VolatileNode[]
7ffe38052d08 2 10,848 System.Collections.Concurrent.ConcurrentDictionary<Autofac.Core.IComponentRegistration, System.Collections.Generic.IEnumerable<Autofac.Core.IComponentRegistration>>+VolatileNode[]
7ffe38184b80 2 10,848 System.Collections.Concurrent.ConcurrentDictionary<System.Reflection.ConstructorInfo, System.Func<System.Object[], System.Object>>+VolatileNode[]
7ffe374a9538 227 10,896 System.Threading.CancellationTokenSource
7ffe38a11850 273 10,920 System.Reflection.Emit.VarArgMethod
7ffe376f56d8 342 10,944 System.Collections.Generic.List<System.Attribute>
7ffe376c7938 159 10,968 System.Reflection.CustomAttributeRecord[]
7ffe39a0f600 52 11,040 Microsoft.Cci.LocalScope[]
7ffe38a69478 198 11,056 Surging.Core.CPlatform.Routing.ServiceAddressDescriptor[]
7ffe375ea878 116 11,136 System.IO.StreamReader
7ffe38503790 233 11,184 System.Net.Http.Headers.HttpRequestHeaders
7ffe384cbcf0 117 11,232 Consul.ConsulClientConfiguration
7ffe376c6120 201 11,256 System.RuntimeType+RuntimeTypeCache+MemberInfoCache<System.Reflection.RuntimeMethodInfo>
7ffe387bd298 88 11,264 System.Xml.XmlTextReaderImpl+NodeData
7ffe37767620 26 11,280 Autofac.Builder.DeferredCallback[]
7ffe39721e80 129 11,288 System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.CSharp.Symbols.FieldOrPropertyInitializer>[]
7ffe3803a118 283 11,320 System.Dynamic.Utils.CacheDict<System.Reflection.MethodBase, System.Reflection.ParameterInfo[]>+Entry
7ffe38551688 118 11,328 System.Net.Security.SslClientAuthenticationOptions
7ffe3a919e80 160 11,520 System.IO.Pipelines.PipeOptions
7ffe375b1408 183 11,712 System.Threading.CancellationTokenSource+Registrations
7ffe39389230 99 11,720 Microsoft.CodeAnalysis.CSharp.Symbols.NamedTypeSymbol[]
7ffe377ce2b0 184 11,776 System.Func<Autofac.IComponentContext, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter>, System.Object>
7ffe377165f8 184 11,776 System.Reflection.InvokerEmitUtil+InvokeFunc_ObjSpanArgs
7ffe37711c20 67 11,792 System.Reflection.Emit.RuntimeMethodBuilder
7ffe38ccc060 296 11,840 Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList+WithTwoChildren
7ffe39af29a0 56 11,904 Microsoft.CodeAnalysis.Emit.EncHoistedLocalInfo[]
7ffe376cb2d0 376 12,032 System.RuntimeTypeHandle[]
7ffe381b6658 377 12,064 System.Runtime.CompilerServices.Closure
7ffe3af46068 116 12,064 System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.Threading.Tasks.VoidTaskResult>+AsyncStateMachineBox<Surging.Core.Consul.WatcherProvider.WatcherBase+<Process>d__1>
7ffe379d62e0 504 12,096 Autofac.Features.Scanning.ScanningRegistrationExtensions+<>c__DisplayClass8_0<System.Object, Autofac.Features.Scanning.ScanningActivatorData, Autofac.Builder.DynamicRegistrationStyle>
7ffe38183520 189 12,096 System.Func<System.Object[], System.Object>
7ffe3801f0b0 171 12,104 Microsoft.Extensions.Logging.LoggerInformation[]
7ffe38169618 260 12,480 System.Collections.Concurrent.ConcurrentDictionary<System.Type, System.Reflection.ConstructorInfo[]>+Node
7ffe377c90b0 521 12,504 Autofac.Core.Lifetime.CurrentScopeLifetime
7ffe3872bb28 112 12,544 System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.Byte[]>+AsyncStateMachineBox<Surging.Core.Consul.Utilitys.ConsulClientExtensions+<GetDataAsync>d__2>
7ffe38979e48 175 12,600 NLog.Internal.TargetWithFilterChain[]
7ffe378d9940 84 12,832 System.Reflection.Emit.__LabelInfo[]
7ffe377f25b0 540 12,960 Autofac.Builder.DynamicRegistrationStyle
7ffe376f02e8 166 13,280 System.ComponentModel.ReflectTypeDescriptionProvider+ReflectedTypeData
7ffe39974ac8 55 13,640 System.Collections.Generic.Dictionary<Microsoft.CodeAnalysis.CSharp.DataFlowPass+VariableIdentifier, System.Int32>+Entry[]
7ffe371eb398 570 13,680 System.UInt64
7ffe3af49348 112 14,336 System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.Threading.Tasks.VoidTaskResult>+AsyncStateMachineBox<Surging.Core.Consul.WatcherProvider.Implementation.NodeMonitorWatcher+<ProcessImpl>d__8>
7ffe38402018 67 14,472 Newtonsoft.Json.Serialization.JsonProperty
7ffe3a290418 308 14,784 System.Collections.Concurrent.ConcurrentDictionary<System.String, System.Type>+Node
7ffe37628c30 125 14,904 Newtonsoft.Json.JsonPosition[]
7ffe3850d528 233 14,912 System.Net.Security.LocalCertificateSelectionCallback
7ffe376af800 421 14,936 System.Reflection.RuntimeConstructorInfo[]
7ffe377cceb8 201 15,048 System.Collections.Generic.HashSet<Autofac.Core.Service>+Entry[]
7ffe3801d660 170 15,200 Microsoft.Extensions.Logging.MessageLogger[]
7ffe3872b3e0 112 15,232 System.Runtime.CompilerServices.AsyncTaskMethodBuilder<Consul.QueryResult<Consul.KVPair>>+AsyncStateMachineBox<Consul.KV+<Get>d__13>
7ffe384c1298 160 15,360 System.Threading.TimerQueueTimer
7ffe380529c8 1 15,472 System.Collections.Concurrent.ConcurrentDictionary<Autofac.Core.Service, Autofac.Core.Registration.ServiceRegistrationInfo>+VolatileNode[]
7ffe3a914b28 244 15,616 System.Collections.Concurrent.ConcurrentDictionary<System.Int64, Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure.ConnectionReference>+Enumerator
7ffe38a13d00 279 15,624 System.Collections.Concurrent.ConcurrentDictionary<System.ValueTuple<System.String, System.String>, System.WeakReference<System.Object>>+Node
7ffe381e26e0 332 15,936 System.Collections.Concurrent.ConcurrentDictionary<System.Reflection.ConstructorInfo, System.Func<System.Object[], System.Object>>+Node
7ffe37fbe338 5 16,128 System.Collections.Concurrent.ConcurrentDictionary<Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceIdentifier, System.Object>+VolatileNode[]
7ffe38146350 253 16,192 System.Func<Autofac.Core.Service, System.Collections.Generic.IEnumerable<Autofac.Core.IComponentRegistration>>
7ffe38146820 225 16,200 Autofac.Features.OpenGenerics.OpenGenericRegistrationSource+<RegistrationsFor>d__3
7ffe3a7ea0e8 677 16,248 log4net.Util.PropertiesDictionary
7ffe377f37e8 508 16,256 Autofac.Features.Scanning.ScanningRegistrationExtensions+<>c__DisplayClass0_0
7ffe379d31c8 508 16,256 System.Collections.Generic.List<System.Func<System.Type, System.Boolean>>
7ffe379d3a10 508 16,256 System.Collections.Generic.List<System.Action<System.Type, Autofac.Builder.IRegistrationBuilder<System.Object, Autofac.Builder.ConcreteReflectionActivatorData, Autofac.Builder.SingleRegistrationStyle>>>
7ffe379d3f50 508 16,256 System.Collections.Generic.List<System.Action<Autofac.Core.IComponentRegistry>>
7ffe3805a998 508 16,256 Autofac.Features.Scanning.ScanningRegistrationExtensions+<>c__DisplayClass3_0
7ffe3aa44808 1 16,408 System.ArraySegment<System.Byte>[]
7ffe37c4fdd0 342 16,416 Surging.Core.CPlatform.Runtime.Server.Implementation.ServiceDiscovery.Implementation.ClrServiceEntryFactory+<>c__DisplayClass7_0
7ffe37ff4168 187 16,456 Microsoft.Extensions.DependencyInjection.ServiceLookup.IEnumerableCallSite
7ffe388eeca8 516 16,512 System.Collections.DictionaryEntry
7ffe37c673f8 259 16,576 Surging.Core.CPlatform.Routing.Implementation.DefaultServiceRouteFactory+<CreateAddress>d__4
7ffe377f24e0 511 16,840 System.Reflection.Assembly[]
7ffe387160c8 147 16,928 System.Byte[][]
7ffe37fbdd10 5 16,992 System.Collections.Concurrent.ConcurrentDictionary<Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCacheKey, Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCallSite>+VolatileNode[]
7ffe381e9288 355 17,040 System.Collections.Concurrent.ConcurrentDictionary<Autofac.Core.IComponentRegistration, System.Collections.Generic.IEnumerable<Autofac.Core.IComponentRegistration>>+Node
7ffe38cff5e8 533 17,056 Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.PredefinedTypeSyntax
7ffe37c4a678 267 17,088 Surging.Core.CPlatform.Utilities.FastInvoke+FastInvokeHandler
7ffe38712e28 720 17,280 Consul.KVPairConverter+<>c__DisplayClass2_0
7ffe37ae7940 197 17,336 Surging.Core.CPlatform.Support.ServiceCommandDescriptor
7ffe37316e58 550 17,600 System.Collections.Generic.List<System.String>
7ffe38cfc5a8 551 17,632 Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.LiteralExpressionSyntax
7ffe385fc008 116 17,632 System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.Net.Http.HttpResponseMessage>+AsyncStateMachineBox<System.Net.Http.RedirectHandler+<SendAsync>d__4>
7ffe38057970 315 17,640 System.Collections.Concurrent.ConcurrentDictionary<System.Guid, System.Object>+Node
7ffe375b1548 221 17,680 System.Threading.CancellationTokenSource+CallbackNode
7ffe37ff3400 492 18,128 Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCallSite[]
7ffe3a818628 324 18,144 log4net.Util.ReusableStringWriter
7ffe37848498 568 18,176 System.Collections.Generic.List<Microsoft.Extensions.DependencyModel.RuntimeAssetGroup>
7ffe37adf008 772 18,528 Autofac.Core.Activators.Reflection.AutowiringParameter
7ffe37adf0c8 772 18,528 Autofac.Core.Activators.Reflection.DefaultValueParameter
7ffe386cd500 116 18,560 System.Runtime.CompilerServices.AsyncTaskMethodBuilder<Consul.QueryResult<Consul.KVPair[]>>+AsyncStateMachineBox<Consul.GetRequest<Consul.KVPair[]>+<Execute>d__10>
7ffe3a91b540 80 18,560 System.Collections.Concurrent.ConcurrentQueueSegment<System.Buffers.MemoryPoolBlock>
7ffe3a91b970 80 18,560 System.Collections.Concurrent.ConcurrentQueueSegment<Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.IOQueue+Work>
7ffe3a91c320 80 18,560 System.Collections.Concurrent.ConcurrentQueueSegment<Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketSender>
7ffe37716b28 596 19,072 System.Reflection.Emit.GenericMethodInfo
7ffe37818570 480 19,200 Microsoft.Extensions.DependencyModel.RuntimeFile
7ffe38508b18 349 19,544 System.Uri+MoreInfo
7ffe376c82f8 308 19,712 System.Reflection.InvokerEmitUtil+InvokeFunc_RefArgs
7ffe377cd060 839 20,136 Autofac.Core.Lifetime.RootScopeLifetime
7ffe378d9bb0 75 20,232 System.Reflection.Emit.__FixupData[]
7ffe377f3858 508 20,320 Autofac.Builder.RegistrationBuilder<System.Object, Autofac.Features.Scanning.ScanningActivatorData, Autofac.Builder.DynamicRegistrationStyle>
7ffe38504dd0 232 20,416 System.UriBuilder
7ffe385fc930 116 20,416 System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.Net.Http.HttpResponseMessage>+AsyncStateMachineBox<System.Net.Http.HttpClient+<<SendAsync>g__Core|83_0>d>
7ffe376f6b88 590 20,592 System.Attribute[]
7ffe3a8182e0 516 20,640 log4net.Util.ConverterInfo
7ffe3976b818 68 20,672 System.Collections.Immutable.RefAsValueType<System.Collections.Immutable.SecurePooledObject<System.Collections.Generic.Stack<System.Collections.Immutable.RefAsValueType<System.Collections.Immutable.SortedInt32KeyNode<System.Collections.Immutable.ImmutableHashSet<Microsoft.CodeAnalysis.CSharp.Symbols.NamedTypeSymbol>+HashBucket>>>>>[]
7ffe376af700 875 21,000 System.RuntimeMethodHandle
7ffe3723aaa0 879 21,096 System.RuntimeTypeHandle
7ffe379d4558 381 21,304 System.Action<System.Type, Autofac.Builder.IRegistrationBuilder<System.Object, Autofac.Builder.ConcreteReflectionActivatorData, Autofac.Builder.SingleRegistrationStyle>>[]
7ffe376c8228 267 21,360 System.Reflection.MethodBaseInvoker
7ffe37493b80 389 21,784 System.Text.RegularExpressions.RegexNode
7ffe389ac2c0 342 21,888 System.Func<System.String, System.Collections.Generic.IDictionary<System.String, System.Object>, System.Threading.Tasks.Task<System.Object>>
7ffe38059328 552 22,080 System.Collections.Generic.Queue<Autofac.Core.IRegistrationSource>
7ffe377c9370 731 23,392 System.Collections.Generic.List<System.EventHandler<Autofac.Core.PreparingEventArgs>>
7ffe377ca1d8 731 23,392 System.Collections.Generic.List<System.EventHandler<Autofac.Core.ActivatingEventArgs<System.Object>>>
7ffe377caf60 731 23,392 System.Collections.Generic.List<System.EventHandler<Autofac.Core.ActivatedEventArgs<System.Object>>>
7ffe376ae8f0 418 23,408 System.RuntimeType+RuntimeTypeCache+MemberInfoCache<System.Reflection.RuntimeConstructorInfo>
7ffe3765f710 737 23,584 System.SZGenericArrayEnumerator<System.String>
7ffe376fdf18 993 23,832 System.Reflection.Emit.DynamicScope
7ffe37cf4340 117 24,336 Consul.ConsulClient
7ffe38cfcd90 509 24,432 Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.InitializerExpressionSyntax
7ffe375ec9c8 124 24,800 Newtonsoft.Json.JsonTextReader
7ffe38c883c8 525 25,200 Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.ArgumentSyntax
7ffe38716a50 396 25,344 System.Action<System.Byte[], System.Byte[]>
7ffe37cbea40 396 25,344 Surging.Core.Consul.WatcherProvider.Implementation.NodeMonitorWatcher
7ffe384c72f8 397 25,408 System.Func<System.Threading.Tasks.ValueTask<Consul.ConsulClient>>
7ffe384c0248 401 25,664 System.Collections.Generic.HashSet<Surging.Core.Consul.WatcherProvider.Watcher>
7ffe386cc678 116 25,984 System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.Net.Http.HttpResponseMessage>+AsyncStateMachineBox<System.Net.Http.HttpConnection+<SendAsync>d__57>
7ffe39d261c8 122 26,352 Microsoft.CodeAnalysis.CodeGen.SwitchIntegralJumpTableEmitter+SwitchBucket[]
7ffe3814c018 4 26,640 System.Collections.Concurrent.ConcurrentDictionary<System.Type, System.Boolean>+VolatileNode[]
7ffe399cf628 62 26,784 System.Collections.Generic.Dictionary<Microsoft.CodeAnalysis.CSharp.Symbols.LocalSymbol, Microsoft.CodeAnalysis.CSharp.CodeGen.LocalDefUseInfo>+Entry[]
7ffe37655f80 481 26,936 System.Uri
7ffe377fe2c0 282 27,072 Microsoft.Extensions.DependencyModel.CompilationLibrary
7ffe3814dd90 679 27,160 System.Collections.Concurrent.ConcurrentDictionary<System.Type, System.Boolean>+Node
7ffe3850a2a8 118 27,376 System.Net.Http.HttpConnectionSettings
7ffe383d3030 124 27,776 Newtonsoft.Json.JsonSerializer
7ffe3a3542d0 3 27,792 System.Text.Encodings.Web.OptimizedInboxTextEncoder
7ffe37ff2860 508 28,448 System.Collections.Concurrent.ConcurrentDictionary<Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceIdentifier, System.Object>+Node
7ffe379d4498 509 28,472 System.Func<System.Type, System.Boolean>[]
7ffe38404a50 116 28,768 Newtonsoft.Json.Serialization.JsonSerializerProxy
7ffe3765ee18 517 28,952 System.Collections.Generic.SortedSet<System.Collections.Generic.KeyValuePair<System.String, System.String>>+Node
7ffe385089b0 362 28,960 System.Uri+UriInfo
7ffe38051168 918 29,376 System.Collections.Generic.List<Autofac.Core.IComponentRegistration>
7ffe376c42b0 283 29,432 System.Reflection.RuntimePropertyInfo
7ffe385070f8 930 29,760 System.Net.Http.Headers.HttpHeaders+HeaderStoreItemInfo
7ffe37be0bf8 342 30,096 Surging.Core.CPlatform.Runtime.Server.ServiceEntry
7ffe39a33378 63 30,504 Microsoft.CodeAnalysis.CSharp.TypeCompilationState+MethodWithBody[]
7ffe38ccbdf0 640 30,720 Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList+WithThreeChildren
7ffe38cfb3b8 550 30,800 Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SyntaxToken+SyntaxTokenWithValueAndTrivia<System.String>
7ffe3a99e2e0 26 30,832 DotNetty.Common.ThreadLocalPool+DefaultHandle[]
7ffe37767068 771 30,840 Autofac.Builder.DeferredCallback
7ffe377c7a08 775 30,968 Autofac.Core.Parameter[]
7ffe37a88b38 655 31,440 Surging.Core.CPlatform.ServiceDescriptor
7ffe385f78f0 116 31,552 System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.Net.Http.HttpResponseMessage>+AsyncStateMachineBox<System.Net.Http.HttpConnectionPool+<SendWithVersionDetectionAndRetryAsync>d__89>
7ffe377f8358 284 31,808 Microsoft.Extensions.DependencyModel.RuntimeLibrary
7ffe373f4880 91 31,920 Microsoft.Extensions.DependencyInjection.ServiceDescriptor[]
7ffe377cf680 969 32,024 Autofac.Core.Service[]
7ffe379d56d0 504 32,256 System.Func<System.Type, System.Collections.Generic.IEnumerable<Autofac.Core.Service>>
7ffe379d3938 504 32,256 System.Action<System.Type, Autofac.Builder.IRegistrationBuilder<System.Object, Autofac.Builder.ConcreteReflectionActivatorData, Autofac.Builder.SingleRegistrationStyle>>
7ffe3a7e0ad8 110 32,560 System.Xml.XmlDocument
7ffe3814c358 2 32,736 System.Collections.Concurrent.ConcurrentDictionary<System.Tuple<System.Type, System.Type>, System.Boolean>+VolatileNode[]
7ffe388c8c78 700 33,600 NLog.Internal.TargetWithFilterChain
7ffe37ff2f48 356 34,176 Microsoft.Extensions.DependencyInjection.ServiceLookup.ConstructorCallSite
7ffe38053330 829 39,792 System.Collections.Concurrent.ConcurrentDictionary<Autofac.Core.Service, Autofac.Core.Registration.ServiceRegistrationInfo>+Node
7ffe39a0b478 61 39,864 Microsoft.Cci.UsedNamespaceOrType[]
7ffe3aa073e8 31 39,864 System.SByte[]
7ffe37fbecd0 626 40,064 System.Collections.Concurrent.ConcurrentDictionary<Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCacheKey, Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCallSite>+Node
7ffe373cdfb0 508 40,640 Autofac.Features.Scanning.ScanningActivatorData
7ffe377c73a0 1,332 42,624 System.Collections.Generic.List<Autofac.Core.Parameter>
7ffe373c5cf8 668 42,752 Microsoft.Extensions.DependencyInjection.ServiceDescriptor
7ffe3a91b700 80 42,880 System.Collections.Concurrent.ConcurrentQueueSegment<System.Buffers.MemoryPoolBlock>+Slot[]
7ffe3a91c4e0 80 42,880 System.Collections.Concurrent.ConcurrentQueueSegment<Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketSender>+Slot[]
7ffe371e94f0 1,789 42,936 System.Int64
7ffe38052800 577 46,360 Autofac.Core.IComponentRegistration[]
7ffe374a0c88 972 46,656 System.Text.StringBuilder
7ffe377c8b30 731 46,784 System.Collections.Generic.HashSet<Autofac.Core.Service>
7ffe377c5780 1,989 47,736 Autofac.Core.TypedService
7ffe3788d300 236 48,632 System.Reflection.MethodInfo[]
7ffe377c5448 771 49,344 System.Action<Autofac.Core.IComponentRegistry>
7ffe376c6230 432 49,944 System.Reflection.RuntimeMethodInfo[]
7ffe377111e8 1,060 50,880 System.Reflection.Emit.ScopeTree
7ffe3781b940 21 52,320 System.Collections.Generic.Dictionary<System.String, System.String>+Entry[]
7ffe3781b6b0 446 52,624 Microsoft.Extensions.DependencyModel.Dependency[]
7ffe3746f5c0 750 54,000 System.Collections.Hashtable
7ffe38cf76c0 1,410 56,400 Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.GenericNameSyntax
7ffe387be230 123 56,968 System.Xml.NameTable+Entry[]
7ffe38507708 581 58,552 System.Net.Http.Headers.HeaderEntry[]
7ffe3a7e3878 110 58,960 System.Xml.XmlName[]
7ffe380518e8 829 59,688 Autofac.Core.Registration.ServiceRegistrationInfo
7ffe376addb0 576 59,904 System.Reflection.RuntimeConstructorInfo
7ffe3a7e6030 1,936 61,952 System.Xml.XmlAttributeCollection
7ffe3a91bb58 80 63,360 System.Collections.Concurrent.ConcurrentQueueSegment<Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.IOQueue+Work>+Slot[]
7ffe387fb068 1 63,904 System.Collections.Generic.Dictionary<System.Enum, NLog.Internal.MruCache<System.Enum, System.String>+MruCacheItem>+Entry[]
7ffe3a9597b8 1,599 63,960 System.Collections.Concurrent.ConcurrentBag<System.String>+Enumerator
7ffe377f26c8 1,048 67,072 System.Func<System.Type, System.Boolean>
7ffe37adeea0 772 67,936 Autofac.Core.Activators.Reflection.ReflectionActivator
7ffe37fbe0a8 5 69,760 System.Collections.Generic.Dictionary<Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceIdentifier, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory+ServiceDescriptorCacheItem>+Entry[]
7ffe377c4520 731 70,176 Autofac.Builder.RegistrationData
7ffe37714118 993 71,496 System.Reflection.Emit.DynamicResolver
7ffe38cf7158 1,502 72,096 Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.TypeArgumentListSyntax
7ffe37888728 1,132 72,448 System.Func<System.String, System.Boolean>
7ffe37711e78 2,283 73,056 System.Collections.Generic.List<System.Object>
7ffe37cbe738 1,584 76,032 Surging.Core.Consul.WatcherProvider.Implementation.ChildWatchRegistration
7ffe38577518 425 79,240 System.Collections.Generic.HashSet<Surging.Core.Consul.WatcherProvider.Watcher>+Entry[]
7ffe377f7ee0 2,625 84,000 System.LazyHelper
7ffe376fe488 1,766 84,768 System.Reflection.Emit.SignatureHelper
7ffe38149318 2,665 85,280 System.Tuple<System.Type, System.Type>
7ffe376c1f68 2,237 86,280 System.Reflection.ParameterInfo[]
7ffe3a2d80d0 1,990 95,520 Jint.Runtime.MruPropertyCache2<System.String, Jint.Runtime.Descriptors.PropertyDescriptor>
7ffe375551e8 1,925 96,480 System.Type[]
7ffe3a2d54d8 1,580 101,120 System.Func<Jint.Native.JsValue, Jint.Native.JsValue[], Jint.Native.JsValue>
7ffe38576770 1,584 101,376 System.Func<Surging.Core.Consul.WatcherProvider.Watcher, System.Boolean>
7ffe3814c810 2,660 106,400 System.Collections.Concurrent.ConcurrentDictionary<System.Tuple<System.Type, System.Type>, System.Boolean>+Node
7ffe37fde410 966 108,192 Autofac.Core.Registration.ComponentRegistration
7ffe3a7e3790 1,540 110,880 System.Xml.XmlName
7ffe3a7cf948 1,980 110,880 System.Xml.XmlElement
7ffe376cb1a8 1,165 111,840 System.RuntimeMethodInfoStub
7ffe37573d50 702 112,320 System.RuntimeType+RuntimeTypeCache
7ffe37556c18 3,299 120,152 System.RuntimeType[]
7ffe38052740 900 122,192 Autofac.Core.IRegistrationSource[]
7ffe3a7e6498 3,080 123,200 System.Xml.XmlAttribute
7ffe3a7e5510 3,080 123,200 System.Xml.XmlText
7ffe3a2d5648 1,580 126,400 Jint.Runtime.Interop.ClrFunctionInstance
7ffe37d250d0 3,172 126,880 System.Collections.Generic.HashSet<Surging.Core.Consul.WatcherProvider.Watcher>+Enumerator
7ffe376fc3a0 993 127,104 System.Reflection.Emit.DynamicMethod
7ffe37491c30 800 137,712 System.Collections.Hashtable+Bucket[]
7ffe387be1c0 3,613 144,520 System.Xml.NameTable+Entry
7ffe376fbd20 993 150,936 System.Reflection.Emit.DynamicILGenerator
7ffe373c31b0 1,633 156,768 System.Threading.ReaderWriterLockSlim
7ffe3a2d8490 1,990 159,200 System.Collections.Generic.Dictionary<System.String, Jint.Runtime.Descriptors.PropertyDescriptor>
7ffe376c01a0 2,062 164,960 System.Signature
7ffe3a2bd480 4,274 170,960 Jint.Native.JsValue
7ffe372d2b28 2,215 177,200 System.Collections.Generic.Dictionary<System.String, System.Object>
7ffe3955b710 67 183,600 System.Collections.Generic.Dictionary<System.Reflection.Metadata.MethodDefinitionHandle, Microsoft.CodeAnalysis.CSharp.Symbols.Metadata.PE.PEMethodSymbol>+Entry[]
7ffe372d7248 2,030 197,136 System.Collections.Generic.Dictionary<System.String, System.Object>+Entry[]
7ffe3a2d7778 4,241 203,568 Jint.Runtime.Descriptors.PropertyDescriptor
7ffe38ccfdf0 4,396 211,008 Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.QualifiedNameSyntax
7ffe384b52c8 4,000 224,000 System.Collections.Generic.SortedSet<System.Collections.Generic.KeyValuePair<System.Int32, Surging.Core.Caching.HashAlgorithms.ConsistentHashNode>>+Node
7ffe38cbbd20 7,283 233,056 Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.IdentifierNameSyntax
7ffe376c0ff0 2,546 244,416 System.Reflection.RuntimeParameterInfo
7ffe3a2d9520 1,940 252,000 System.Collections.Generic.Dictionary<System.String, Jint.Runtime.Descriptors.PropertyDescriptor>+Entry[]
7ffe376c1ca8 2,474 257,296 System.Reflection.RuntimeMethodInfo
7ffe38cba2c0 4 272,000 Microsoft.CodeAnalysis.ArrayElement<Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SyntaxToken>[]
7ffe37185fa8 14,368 344,832 System.Object
7ffe3718a1d0 11,062 442,480 System.RuntimeType
7ffe38cba618 11,217 448,680 Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SyntaxToken+SyntaxTokenWithTrivia
7ffe387fa978 1 484,968 System.Collections.Generic.Dictionary<System.Type, NLog.Internal.MruCache<System.Type, System.Collections.Generic.KeyValuePair<System.Reflection.PropertyInfo[], NLog.Internal.ReflectionHelpers+LateBoundMethod[]>>+MruCacheItem>+Entry[]
7ffe38c88c28 8,693 556,352 Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SyntaxToken+SyntaxIdentifierWithTrivia
7ffe372ddb78 2,944 581,048 System.String[]
7ffe37238318 6,671 591,516 System.Int32[]
7ffe3718c1c8 3,410 830,864 System.Object[]
7ffe38cbc268 1 1,048,600 Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxNodeCache+Entry[]
7ffe39289da8 1 1,048,600 Roslyn.Utilities.StringTable+Entry[]
7ffe37576c28 8,433 1,468,669 System.Byte[]
7ffe3739d578 1,466 2,027,490 System.Char[]
000000c1c880 1,725 2,162,896 Free
7ffe3723cf88 82,411 6,445,384 System.String
通过以上呈现的分析结果,发现有类型Microsoft.CodeAnalysis.Syntax,Roslyn停留在内存得不到回收,而这些就是Roslyn动态编译的缓存数据,
然后用VS可以看到具体内容
1.Roslyn.Utilities.StringTable+Entry[]
2.Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxNodeCache+Entry[]
三、代码修改
得到社区提醒帮助,然后着手修改,
1.以surging 为例,首先先独立新的模块Surging.Core.ProxyGenerator.Extensions,把CompilationUtilitys.cs 和ServiceProxyGenerater.cs文件添加进来,以便更好的卸载,效果如下
2.创建CustomAssemblyLoadContext,代码如下:
public class CustomAssemblyLoadContext : AssemblyLoadContext
{
private string _assemblyDirectory;
public CustomAssemblyLoadContext(string assemblyDirectory)
: base(isCollectible: true)
{
_assemblyDirectory = assemblyDirectory;
}
protected override Assembly Load(AssemblyName assemblyName)
{
var assemblyPath = Path.Combine(_assemblyDirectory, $"{assemblyName.Name}.dll");
if (File.Exists(assemblyPath))
{
return LoadFromAssemblyPath(assemblyPath);
}
return null;
}
}
3.装卸载Surging.Core.ProxyGenerator.Extensions,通过ServiceLocator.IsRegistered<IServiceProxyGenerater>判断就可以选择性使用,代码如下:
public void RegisterProxType(string[] namespaces,params Type[] types)
{
if (!ServiceLocator.IsRegistered<IServiceProxyGenerater>())
{
var loading = LoadAssembly(Path.Combine(AppContext.BaseDirectory, "Surging.Core.ProxyGenerator.Extensions.dll"));
InvokeFunc(loading.assembly, types, namespaces);
loading.loadContext.Unload();
}
else
{
var proxyGenerater = _serviceProvider.GetService<IServiceProxyGenerater>();
var serviceTypes = proxyGenerater.GenerateProxys(types, namespaces).ToArray();
_serviceTypes = _serviceTypes.Except(serviceTypes).Concat(serviceTypes).ToArray();
proxyGenerater.Dispose();
GC.WaitForPendingFinalizers();
GC.Collect();
}
}
public void InvokeFunc(Assembly assembly, Type[] types,string[] namespaces)
{
var type = assembly.GetType("Surging.Core.ProxyGenerator.Extensions.ServiceProxyGenerater");
DefaultServiceIdGenerator serviceIdGenerator = _serviceProvider.GetService<IServiceIdGenerator>() as DefaultServiceIdGenerator;
var logger = _serviceProvider.GetService<ILogger<ServiceProxyFactory>>();
var obj = assembly.CreateInstance("Surging.Core.ProxyGenerator.Extensions.ServiceProxyGenerater");
var methodGenerateProxys = type.GetMethod("GenerateProxys");
var serviceTypes = methodGenerateProxys.Invoke(obj, new object[] { types, namespaces });
_serviceTypes = _serviceTypes.Except(serviceTypes as Type[]).Concat(serviceTypes as Type[]).ToArray();
var methodDispose = type.GetMethod("Dispose");
methodDispose.Invoke(obj, null);
}
4.把AddRelateService改成AddRelateService2就能卸载清空缓存数据了
var host = new ServiceHostBuilder()
.RegisterServices(builder =>
{
builder.AddMicroService(option =>
{
option.AddServiceRuntime()
// .AddRelateService() // no unload Proxy Generator
.AddRelateService2()//load and unload Proxy Generator
.AddConfigurationWatch()
//option.UseZooKeeperManager(new ConfigInfo("127.0.0.1:2181"));
.AddServiceEngine(typeof(SurgingServiceEngine));
builder.Register(p => new CPlatformContainer(ServiceLocator.Current));
});
})
.ConfigureLogging(logger =>
{
logger.AddConfiguration(
Core.CPlatform.AppConfig.GetSection("Logging"));
})
.UseServer(options => { })
.UseProxy()
.UseConsoleLifetime()
.Configure(build =>
build.AddCacheFile("${cachepath}|cacheSettings.json", basePath: AppContext.BaseDirectory, optional: false, reloadOnChange: true))
.Configure(build =>
build.AddCPlatformFile("${surgingpath}|surgingSettings.json", optional: false, reloadOnChange: true))
.Configure(build => build.UseApollo(apollo => apollo.AddNamespaceSurgingApollo("surgingSettings")))
.UseStartup<Startup>()
.Build();
using (host.Run())
{
Console.WriteLine($"服务端启动成功,{DateTime.Now}。");
}
再然后通过dump 分析一下结果:
7ffc433841a8 157 10,048 System.Reflection.RuntimeModule
7ffc435055d0 257 10,280 System.ComponentModel.AttributeCollection
7ffc43f7cd00 258 10,320 System.Collections.Concurrent.ConcurrentDictionary<System.Type, System.Boolean>+Node
7ffc443b49f0 1 10,368 System.Collections.Generic.Dictionary<System.String, System.Collections.Generic.HashSet<Surging.Core.Consul.WatcherProvider.Watcher>>+Entry[]
7ffc433857e0 221 10,608 System.Reflection.RuntimeAssembly
7ffc466bd7e0 20 10,720 System.Collections.Concurrent.ConcurrentQueueSegment<System.Buffers.MemoryPoolBlock>+Slot[]
7ffc466be5c0 20 10,720 System.Collections.Concurrent.ConcurrentQueueSegment<Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.SocketSender>+Slot[]
7ffc43409240 96 10,752 Newtonsoft.Json.Linq.JObject
7ffc431ddcb0 193 10,808 Autofac.Builder.SingleRegistrationStyle
7ffc44858cf8 273 10,920 System.Reflection.Emit.VarArgMethod
7ffc435056d8 342 10,944 System.Collections.Generic.List<System.Attribute>
7ffc4718a510 114 10,944 System.Collections.Generic.Dictionary<DotNetty.Codecs.Rtmp.Stream.StreamName, DotNetty.Codecs.Rtmp.Messages.AbstractRtmpMessage>+Entry[]
7ffc4343bc00 108 11,232 Newtonsoft.Json.Linq.JProperty
7ffc43520018 67 11,256 System.Reflection.Emit.RuntimeTypeBuilder
7ffc435261a0 176 11,264 System.Reflection.InvokerEmitUtil+InvokeFunc_ObjSpanArgs
7ffc43577620 26 11,280 Autofac.Builder.DeferredCallback[]
7ffc43e75c28 207 11,592 System.Collections.Concurrent.ConcurrentDictionary<System.Guid, System.Object>+Node
7ffc43492870 182 11,648 System.Func<System.Object>
7ffc47184bc0 243 11,664 DotNetty.Codecs.Rtmp.Messages.AudioMessage
7ffc435073c8 114 11,856 System.ComponentModel.AttributeCollection+AttributeEntry[]
7ffc44008800 247 11,856 System.Collections.Concurrent.ConcurrentDictionary<Autofac.Core.IComponentRegistration, System.Collections.Generic.IEnumerable<Autofac.Core.IComponentRegistration>>+Node
7ffc435ddf88 186 11,904 System.Func<Autofac.IComponentContext, System.Collections.Generic.IEnumerable<Autofac.Core.Parameter>, System.Object>
7ffc43fb2488 189 12,096 System.Func<System.Object[], System.Object>
7ffc43504d28 256 12,288 System.Collections.Concurrent.ConcurrentDictionary<System.Type, System.ComponentModel.ReflectTypeDescriptionProvider+ReflectedTypeData>+Node
7ffc43804618 512 12,288 Autofac.Features.Scanning.ScanningRegistrationExtensions+<>c__DisplayClass8_0<System.Object, Autofac.Features.Scanning.ScanningActivatorData, Autofac.Builder.DynamicRegistrationStyle>
7ffc43e3d2f0 177 12,440 Microsoft.Extensions.Logging.LoggerInformation[]
7ffc448ad048 392 12,544 System.Collections.Generic.List<Surging.Core.CPlatform.Routing.ServiceAddressDescriptor>
7ffc439f19e0 392 12,544 Surging.Core.CPlatform.Routing.ServiceAddressDescriptor
7ffc435d90b0 525 12,600 Autofac.Core.Lifetime.CurrentScopeLifetime
7ffc43502a80 272 13,056 System.Collections.Concurrent.ConcurrentDictionary<System.Type, System.Object>+Node
7ffc43602210 548 13,152 Autofac.Builder.DynamicRegistrationStyle
7ffc43508448 118 13,184 System.Reflection.RuntimeFieldInfo[][]
7ffc43c31600 281 13,488 DotNetty.Common.Utilities.AsciiString
7ffc43e3b8a0 165 14,200 Microsoft.Extensions.Logging.MessageLogger[]
7ffc434d63f0 288 14,288 System.Reflection.RuntimePropertyInfo[]
7ffc434d82f8 230 14,720 System.Reflection.InvokerEmitUtil+InvokeFunc_RefArgs
7ffc443bedc0 46 14,720 System.Collections.Concurrent.ConcurrentDictionary<System.Type, Newtonsoft.Json.Serialization.JsonContract>+VolatileNode[]
7ffc45f9f5b0 308 14,784 System.Collections.Concurrent.ConcurrentDictionary<System.String, System.Type>+Node
7ffc4453b860 232 14,848 System.Action<System.Object, System.Object>
7ffc44223f68 621 14,904 Newtonsoft.Json.Serialization.ReflectionAttributeProvider
7ffc4387cee8 467 14,944 Surging.Core.CPlatform.Routing.ServiceRoute
7ffc435dcb90 203 15,192 System.Collections.Generic.HashSet<Autofac.Core.Service>+Entry[]
7ffc443bebf8 47 15,208 Newtonsoft.Json.DefaultJsonNameTable+Entry[]
7ffc43126e58 479 15,328 System.Collections.Generic.List<System.String>
7ffc43ddc5a0 4 15,392 System.Collections.Concurrent.ConcurrentDictionary<Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceIdentifier, System.Object>+VolatileNode[]
7ffc43ddbf78 4 15,392 System.Collections.Concurrent.ConcurrentDictionary<Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCacheKey, Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCallSite>+VolatileNode[]
7ffc43e70c80 1 15,472 System.Collections.Concurrent.ConcurrentDictionary<Autofac.Core.Service, Autofac.Core.Registration.ServiceRegistrationInfo>+VolatileNode[]
7ffc444d9820 1 15,472 System.Collections.Concurrent.ConcurrentDictionary<System.Object, Newtonsoft.Json.JsonConverterAttribute>+VolatileNode[]
7ffc466bdc38 20 15,840 System.Collections.Concurrent.ConcurrentQueueSegment<Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.Internal.IOQueue+Work>+Slot[]
7ffc435264d0 122 16,208 System.Reflection.RuntimePropertyInfo[][]
7ffc43e775e0 407 16,280 System.Collections.Generic.Queue<Autofac.Core.IRegistrationSource>
7ffc434d6120 291 16,296 System.RuntimeType+RuntimeTypeCache+MemberInfoCache<System.Reflection.RuntimeMethodInfo>
7ffc43a6dc78 342 16,416 Surging.Core.CPlatform.Runtime.Server.Implementation.ServiceDiscovery.Implementation.ClrServiceEntryFactory+<>c__DisplayClass7_0
7ffc43e78c50 516 16,512 Autofac.Features.Scanning.ScanningRegistrationExtensions+<>c__DisplayClass3_0
7ffc43603448 516 16,512 Autofac.Features.Scanning.ScanningRegistrationExtensions+<>c__DisplayClass0_0
7ffc43801500 516 16,512 System.Collections.Generic.List<System.Func<System.Type, System.Boolean>>
7ffc43801d48 516 16,512 System.Collections.Generic.List<System.Action<System.Type, Autofac.Builder.IRegistrationBuilder<System.Object, Autofac.Builder.ConcreteReflectionActivatorData, Autofac.Builder.SingleRegistrationStyle>>>
7ffc43802288 516 16,512 System.Collections.Generic.List<System.Action<Autofac.Core.IComponentRegistry>>
7ffc434308b8 259 16,576 System.Threading.ContextCallback
7ffc43a68520 267 17,088 Surging.Core.CPlatform.Utilities.FastInvoke+FastInvokeHandler
7ffc43602140 519 17,096 System.Reflection.Assembly[]
7ffc438f4900 196 17,248 Surging.Core.CPlatform.Support.ServiceCommandDescriptor
7ffc43e12290 199 17,512 Microsoft.Extensions.DependencyInjection.ServiceLookup.IEnumerableCallSite
7ffc4485b1a8 324 18,144 System.Collections.Concurrent.ConcurrentDictionary<System.ValueTuple<System.String, System.String>, System.WeakReference<System.Object>>+Node
7ffc43658498 570 18,240 System.Collections.Generic.List<Microsoft.Extensions.DependencyModel.RuntimeAssetGroup>
7ffc434d8228 230 18,400 System.Reflection.MethodBaseInvoker
7ffc438ebfb0 772 18,528 Autofac.Core.Activators.Reflection.AutowiringParameter
7ffc438ec070 772 18,528 Autofac.Core.Activators.Reflection.DefaultValueParameter
7ffc43523ba8 179 18,976 System.Reflection.RuntimeMethodInfo[][]
7ffc43628570 480 19,200 Microsoft.Extensions.DependencyModel.RuntimeFile
7ffc43e11528 522 19,424 Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCallSite[]
7ffc434bf8a0 537 20,096 System.Reflection.RuntimeConstructorInfo[]
7ffc435dcd38 843 20,232 Autofac.Core.Lifetime.RootScopeLifetime
7ffc435002e8 256 20,480 System.ComponentModel.ReflectTypeDescriptionProvider+ReflectedTypeData
7ffc436034b8 516 20,640 Autofac.Builder.RegistrationBuilder<System.Object, Autofac.Features.Scanning.ScanningActivatorData, Autofac.Builder.DynamicRegistrationStyle>
7ffc43802890 387 21,640 System.Action<System.Type, Autofac.Builder.IRegistrationBuilder<System.Object, Autofac.Builder.ConcreteReflectionActivatorData, Autofac.Builder.SingleRegistrationStyle>>[]
7ffc4453ec98 99 21,776 System.Byte[][]
7ffc44853840 342 21,888 System.Func<System.String, System.Collections.Generic.IDictionary<System.String, System.Object>, System.Threading.Tasks.Task<System.Object>>
7ffc448ad628 393 21,976 Surging.Core.CPlatform.Routing.ServiceAddressDescriptor[]
7ffc446fe7b0 460 22,080 NLog.Internal.TargetWithFilterChain
7ffc4453c660 108 23,664 System.Collections.Generic.Dictionary<System.String, Newtonsoft.Json.Serialization.JsonProperty>+Entry[]
7ffc435d9370 741 23,712 System.Collections.Generic.List<System.EventHandler<Autofac.Core.PreparingEventArgs>>
7ffc435da1d8 741 23,712 System.Collections.Generic.List<System.EventHandler<Autofac.Core.ActivatingEventArgs<System.Object>>>
7ffc435daf60 741 23,712 System.Collections.Generic.List<System.EventHandler<Autofac.Core.ActivatedEventArgs<System.Object>>>
7ffc432a14f0 29 23,952 System.Collections.Hashtable+Bucket[]
7ffc441fe098 613 24,520 Newtonsoft.Json.Serialization.ExpressionValueProvider
7ffc43a75300 392 25,088 Surging.Core.CPlatform.Routing.Implementation.DefaultServiceRouteFactory+<CreateAddress>d__4
7ffc4453f620 394 25,216 System.Action<System.Byte[], System.Byte[]>
7ffc43adc258 394 25,216 Surging.Core.Consul.WatcherProvider.Implementation.NodeMonitorWatcher
7ffc44315d58 395 25,280 System.Func<System.Threading.Tasks.ValueTask<Consul.ConsulClient>>
7ffc442fec88 395 25,280 System.Collections.Generic.HashSet<Surging.Core.Consul.WatcherProvider.Watcher>
7ffc43696870 400 25,600 System.Func<System.String, System.Boolean>
7ffc435266d0 817 26,144 System.Reflection.Emit.GenericMethodInfo
7ffc4350b828 196 26,656 System.Reflection.Emit.RuntimeILGenerator
7ffc4360df20 283 27,168 Microsoft.Extensions.DependencyModel.CompilationLibrary
7ffc46562c60 92 27,232 System.Xml.XmlDocument
7ffc43506b88 765 28,088 System.Attribute[]
7ffc443b7d60 395 28,440 System.Collections.Generic.HashSet<Surging.Core.Consul.WatcherProvider.Watcher>+Entry[]
7ffc4346ee18 515 28,840 System.Collections.Generic.SortedSet<System.Collections.Generic.KeyValuePair<System.String, System.String>>+Node
7ffc438027d0 517 28,920 System.Func<System.Type, System.Boolean>[]
7ffc43e6f380 917 29,344 System.Collections.Generic.List<Autofac.Core.IComponentRegistration>
7ffc444da518 613 29,424 System.Collections.Concurrent.ConcurrentDictionary<System.Object, Newtonsoft.Json.JsonConverterAttribute>+Node
7ffc44220038 109 29,648 Newtonsoft.Json.Serialization.JsonObjectContract
7ffc434be990 537 30,072 System.RuntimeType+RuntimeTypeCache+MemberInfoCache<System.Reflection.RuntimeConstructorInfo>
7ffc439ce4c0 342 30,096 Surging.Core.CPlatform.Runtime.Server.ServiceEntry
7ffc43e10988 547 30,632 System.Collections.Concurrent.ConcurrentDictionary<Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceIdentifier, System.Object>+Node
7ffc435d7a08 774 30,928 Autofac.Core.Parameter[]
7ffc442f1630 487 31,168 System.Func<System.Object, System.Object>
7ffc43577068 781 31,240 Autofac.Builder.DeferredCallback
7ffc43204880 89 31,672 Microsoft.Extensions.DependencyInjection.ServiceDescriptor[]
7ffc43607fb8 285 31,920 Microsoft.Extensions.DependencyModel.RuntimeLibrary
7ffc440aadc8 665 31,920 DotNetty.Common.ThreadLocalPool+DefaultHandle
7ffc435df358 970 32,032 Autofac.Core.Service[]
7ffc43803a08 512 32,768 System.Func<System.Type, System.Collections.Generic.IEnumerable<Autofac.Core.Service>>
7ffc43801c70 512 32,768 System.Action<System.Type, Autofac.Builder.IRegistrationBuilder<System.Object, Autofac.Builder.ConcreteReflectionActivatorData, Autofac.Builder.SingleRegistrationStyle>>
7ffc434dac78 472 33,984 System.Reflection.RtFieldInfo
7ffc46853b60 11 34,024 System.ArraySegment<System.Byte>[]
7ffc42ff94f0 1,424 34,176 System.Int64
7ffc43521c20 196 34,496 System.Reflection.Emit.RuntimeMethodBuilder
7ffc43895a10 734 35,232 Surging.Core.CPlatform.ServiceDescriptor
7ffc43fd5598 1,124 35,968 System.Runtime.CompilerServices.Closure
7ffc436e7a30 225 36,344 System.Reflection.Emit.__LabelInfo[]
7ffc4488f700 115 36,800 System.Collections.Concurrent.ConcurrentDictionary<System.String, System.Object>+VolatileNode[]
7ffc434bf7a0 1,540 36,960 System.RuntimeMethodHandle
7ffc46083970 4 37,056 System.Text.Encodings.Web.OptimizedInboxTextEncoder
7ffc43e11070 398 38,208 Microsoft.Extensions.DependencyInjection.ServiceLookup.ConstructorCallSite
7ffc43e715e8 829 39,792 System.Collections.Concurrent.ConcurrentDictionary<Autofac.Core.Service, Autofac.Core.Registration.ServiceRegistrationInfo>+Node
7ffc431ddfb0 516 41,280 Autofac.Features.Scanning.ScanningActivatorData
7ffc43e70ab8 562 41,392 Autofac.Core.IComponentRegistration[]
7ffc431d5cf8 650 41,600 Microsoft.Extensions.DependencyInjection.ServiceDescriptor
7ffc435d73a0 1,348 43,136 System.Collections.Generic.List<Autofac.Core.Parameter>
7ffc4362b940 12 43,488 System.Collections.Generic.Dictionary<System.String, System.String>+Entry[]
7ffc43ddcf38 684 43,776 System.Collections.Concurrent.ConcurrentDictionary<Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCacheKey, Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCallSite>+Node
7ffc4350df18 1,868 44,832 System.Reflection.Emit.DynamicScope
7ffc43364be8 289 45,160 System.Type[]
7ffc435d5780 1,902 45,648 Autofac.Core.TypedService
7ffc435d8b30 741 47,424 System.Collections.Generic.HashSet<Autofac.Core.Service>
7ffc4304aaa0 2,014 48,336 System.RuntimeTypeHandle
7ffc46565a00 92 49,312 System.Xml.XmlName[]
7ffc44612830 92 49,312 System.Xml.NameTable+Entry[]
7ffc435d5448 781 49,984 System.Action<Autofac.Core.IComponentRegistry>
7ffc4362b6b0 450 52,816 Microsoft.Extensions.DependencyModel.Dependency[]
7ffc465681b8 1,656 52,992 System.Xml.XmlAttributeCollection
7ffc43e6fb00 829 59,688 Autofac.Core.Registration.ServiceRegistrationInfo
7ffc436e7ca0 225 60,504 System.Reflection.Emit.__FixupData[]
7ffc446d1150 1 63,904 System.Collections.Generic.Dictionary<System.Enum, NLog.Internal.MruCache<System.Enum, System.String>+MruCacheItem>+Entry[]
7ffc467b8340 42 66,288 DotNetty.Common.ThreadLocalPool+DefaultHandle[]
7ffc43f7b2c8 2 67,696 System.Collections.Concurrent.ConcurrentDictionary<System.Tuple<System.Type, System.Type>, System.Boolean>+VolatileNode[]
7ffc43602328 1,060 67,840 System.Func<System.Type, System.Boolean>
7ffc438ebe48 772 67,936 Autofac.Core.Activators.Reflection.ReflectionActivator
7ffc43ddc310 4 69,056 System.Collections.Generic.Dictionary<Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceIdentifier, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory+ServiceDescriptorCacheItem>+Entry[]
7ffc43e709f8 409 70,008 Autofac.Core.IRegistrationSource[]
7ffc435d4520 741 71,136 Autofac.Builder.RegistrationData
7ffc44157a40 649 72,688 DotNetty.Transport.Channels.ChannelOutboundBuffer+Entry
7ffc434d6230 383 75,616 System.Reflection.RuntimeMethodInfo[]
7ffc45ff74d8 1,592 76,416 Jint.Runtime.MruPropertyCache2<System.String, Jint.Runtime.Descriptors.PropertyDescriptor>
7ffc434d42b0 756 78,624 System.Reflection.RuntimePropertyInfo
7ffc45ff48e0 1,264 80,896 System.Func<Jint.Native.JsValue, Jint.Native.JsValue[], Jint.Native.JsValue>
7ffc43f78288 2,680 85,760 System.Tuple<System.Type, System.Type>
7ffc43521e78 2,894 92,608 System.Collections.Generic.List<System.Object>
7ffc46565918 1,288 92,736 System.Xml.XmlName
7ffc46561b20 1,656 92,736 System.Xml.XmlElement
7ffc434bde50 901 93,704 System.Reflection.RuntimeConstructorInfo
7ffc435211e8 2,064 99,072 System.Reflection.Emit.ScopeTree
7ffc45ff4a50 1,264 101,120 Jint.Runtime.Interop.ClrFunctionInstance
7ffc46568620 2,576 103,040 System.Xml.XmlAttribute
7ffc46567698 2,576 103,040 System.Xml.XmlText
7ffc43f7b780 2,680 107,200 System.Collections.Concurrent.ConcurrentDictionary<System.Tuple<System.Type, System.Type>, System.Boolean>+Node
7ffc43dfc5e0 968 108,416 Autofac.Core.Registration.ComponentRegistration
7ffc42f95fa8 4,539 108,936 System.Object
7ffc433837d0 691 110,560 System.RuntimeType+RuntimeTypeCache
7ffc430edb78 798 111,592 System.String[]
7ffc446127c0 2,944 117,760 System.Xml.NameTable+Entry
7ffc4350e488 2,533 121,584 System.Reflection.Emit.SignatureHelper
7ffc45ff7898 1,592 127,360 System.Collections.Generic.Dictionary<System.String, Jint.Runtime.Descriptors.PropertyDescriptor>
7ffc442209d8 621 134,136 Newtonsoft.Json.Serialization.JsonProperty
7ffc43524118 1,868 134,496 System.Reflection.Emit.DynamicResolver
7ffc45fdc8a0 3,420 136,800 Jint.Native.JsValue
7ffc434d1f68 3,760 140,304 System.Reflection.ParameterInfo[]
7ffc45ff6b80 3,393 162,864 Jint.Runtime.Descriptors.PropertyDescriptor
7ffc434db1a8 1,868 179,328 System.RuntimeMethodInfoStub
7ffc430e2b28 2,368 189,440 System.Collections.Generic.Dictionary<System.String, System.Object>
7ffc45ff8928 1,552 201,600 System.Collections.Generic.Dictionary<System.String, Jint.Runtime.Descriptors.PropertyDescriptor>+Entry[]
7ffc442f3d10 4,000 224,000 System.Collections.Generic.SortedSet<System.Collections.Generic.KeyValuePair<System.Int32, Surging.Core.Caching.HashAlgorithms.ConsistentHashNode>>+Node
7ffc430e7248 2,301 224,064 System.Collections.Generic.Dictionary<System.String, System.Object>+Entry[]
7ffc4350c3a0 1,868 239,104 System.Reflection.Emit.DynamicMethod
7ffc43366618 7,471 260,456 System.RuntimeType[]
7ffc4350bd20 1,868 283,936 System.Reflection.Emit.DynamicILGenerator
7ffc431ad580 65 310,632 System.Char[]
7ffc434d01a0 5,568 445,440 System.Signature
7ffc42f9a1d0 11,850 474,000 System.RuntimeType
7ffc43048318 6,101 483,960 System.Int32[]
7ffc446d0bc0 1 484,968 System.Collections.Generic.Dictionary<System.Type, NLog.Internal.MruCache<System.Type, System.Collections.Generic.KeyValuePair<System.Reflection.PropertyInfo[], NLog.Internal.ReflectionHelpers+LateBoundMethod[]>>+MruCacheItem>+Entry[]
7ffc42f9c1c8 3,601 525,960 System.Object[]
7ffc434d0ff0 5,713 548,448 System.Reflection.RuntimeParameterInfo
7ffc434d1ca8 6,597 686,088 System.Reflection.RuntimeMethodInfo
7ffc46816bc0 15 791,400 System.SByte[]
7ffc4304cf88 30,474 2,268,506 System.String
7ffc433866a8 13,370 3,376,813 System.Byte[]
007089235cd0 454 39,605,776 Free
Total 255,601 objects, 60,449,965 bytes
通过以上分析发现缓存数据没有了,最近有很多国外友人进行测试访问,udp,tcp,mqtt,sip,rtmp都在进行测试,发现有些内存碎片化的free 得不到立即回收,到时候花时间看看。