International Journal on Science and Technology

E-ISSN: 2229-7677     Impact Factor: 9.88

A Widely Indexed Open Access Peer Reviewed Multidisciplinary Bi-monthly Scholarly International Journal

Call for Paper Volume 16 Issue 1 January-March 2025 Submit your research before last 3 days of March to publish your research paper in the issue of January-March.

An Empirical Study of Dependency Injection Lifetime Effects in C# Applications

Author(s) AzraJabeen Mohamed Ali
Country United States
Abstract This empirical study investigates the effects of different Dependency Injection (DI) lifetimes in C# applications, focusing on their impact on performance, resource management, and maintainability. DI lifetimes—such as Transient, Scoped, and Singleton—play a crucial role in the lifecycle of objects and services within a system. While DI frameworks, such as Microsoft.Extensions.DependencyInjection, offer flexibility in managing these lifetimes, the practical consequences of each scope on large-scale C# applications remain underexplored. Through a series of controlled experiments, we analyze key metrics including memory usage, application startup time, response times, and ease of unit testing across varying lifetimes. The study also examines the trade-offs between performance and maintainability, providing insights into best practices for choosing appropriate lifetimes in different architectural contexts. Our findings reveal how improper DI lifetime choices can lead to resource inefficiencies and reduced application scalability, while also highlighting the benefits of well-managed scopes for improving code quality and testability. Ultimately, this research contributes to a deeper understanding of DI lifetime management and offers actionable recommendations for developers to optimize their C# applications' design and performance.
Keywords Dependency Injection, lifetime, Transient, Scoped, Singleton, lifecycle, Service provider, Service Collection
Published In Volume 14, Issue 2, April-June 2023
Published On 2023-04-05
Cite This An Empirical Study of Dependency Injection Lifetime Effects in C# Applications - AzraJabeen Mohamed Ali - IJSAT Volume 14, Issue 2, April-June 2023. DOI 10.5281/zenodo.14613867
DOI https://doi.org/10.5281/zenodo.14613867
Short DOI https://doi.org/g8x2wp

Share this