jab
jab copied to clipboard
Memory leak issue caused by IDisposable (?)
I am trying to understand the generated code and found out that there is List<object>? _disposables;
which keeps the IDisposable
object from the service, but I think that also causes the object to leak(?), here is the test to check if the object is leaking:
var p = new MyServiceProvider();
WeakReference w = new(null);
var i = new Action(() =>
{
var service = p.GetService<IService>();
w.Target = service;
});
i();
GC.Collect();
Console.WriteLine($"Is the object still alive? {w.IsAlive}");
If the service doesn't implement IDisposable the object didn't leak, but if it does it leak
My use case is that the provider is alive as long as the app still running, I am using dotnet android