❔ Garbage collection question
I see in many libraries examples where in DI ".AddScoped<>", ".AddTransient<>" is used instead of ".AddSingleton<>", example in fluent assertions example says:
What do you think? is it better to use Transient/Scoped even when singleton make sense from memory point of view?
services.AddScoped<IValidator<User>, UserValidator>(); and i wonder why? this class instance is sorto "read only" so it could be singleton? And here's my question regarding that, because singleton will create long lived instanced meanwhile the other two will live for let's say 100ms, they will be regularly cleared, less often reach further generation. I know that not all singletons are used at all time, they will live in memory for long time and cause extra pressure on garbage colletor.What do you think? is it better to use Transient/Scoped even when singleton make sense from memory point of view?