diff --git a/src/Spark.AspNetCore.Mvc/Extensions/ServiceCollectionExtensions.cs b/src/Spark.AspNetCore.Mvc/Extensions/ServiceCollectionExtensions.cs index 034d8aa0..837e06d0 100644 --- a/src/Spark.AspNetCore.Mvc/Extensions/ServiceCollectionExtensions.cs +++ b/src/Spark.AspNetCore.Mvc/Extensions/ServiceCollectionExtensions.cs @@ -34,37 +34,37 @@ public static IServiceCollection AddSpark(this IServiceCollection services, Acti services.Configure(setupAction); } - // TODO: Reduce memory consumption cause by loading the assembly of the views compiled dynamically services - .AddSingleton() - .AddSingleton() - .AddSingleton() - .AddSingleton(); + .AddScoped() + .AddScoped() + .AddScoped() + .AddScoped(); services - .AddSingleton() - .AddSingleton() + .AddScoped() + .AddScoped() .AddSingleton() .AddSingleton() .AddSingleton() - .AddSingleton() + .AddScoped() .AddSingleton(f => f.GetService().CreateDefaultViewFolder()) .AddSingleton() .AddSingleton() .AddSingleton(); - services.AddSingleton(c => null); + services + .AddSingleton(f => null); services .AddSingleton(); services - .AddSingleton(); + .AddScoped(); services .AddTransient, SparkMvcOptionsSetup>() .AddTransient, SparkMvcViewOptionsSetup>() - .AddSingleton(); + .AddScoped(); return services; }