volosoft / castle-windsor-ms-adapter

Castle Windsor ASP.NET Core / Microsoft.Extensions.DependencyInjection Adapter
https://www.nuget.org/packages/Castle.Windsor.MsDependencyInjection
MIT License
85 stars 29 forks source link

Call CreateScope directly, Dispose does not work properly #42

Open NepPure opened 2 years ago

NepPure commented 2 years ago

detail and demo see https://github.com/aspnetboilerplate/aspnetboilerplate/issues/6293

https://github.com/Cysharp/MagicOnion/blob/8d73bfadc2cf7e59bf4fb08e0ba2d3263541323a/src/MagicOnion.Server/MethodHandler.cs?_pjax=%23js-repo-pjax-container%2C%20div%5Bitemtype%3D%22http%3A%2F%2Fschema.org%2FSoftwareSourceCode%22%5D%20main%2C%20%5Bdata-pjax-container%5D#L349

I find the problem when using Abp with MagicOnion.

It calls WindsorServiceScopeFactory.CreateScope directly, when disposeing the MsLifetimeScope may be not the same instance.

MsLifetimeScope._resolvedInstances will be more and more long, then out of memory.

I tried to debug it, and I did not find the most fundamental reason. I hope get some help, thank you very much!