Exactly how long is `InSingletonScope` for a webapp?

asp.net-mvc-4, c#, ninject

Solution

It would last as long as your ASP.NET application pool lasts.

When will your application pool recycle? There are many settings which govern this: have a read of Configuring Recycling Settings for an Application Pool (IIS 7).

Basically, though, it ain't gonna be forever: if you want to store read-only data in there, just make sure you load it all up in `Application_Start()` so it's ready when requests come in, and you should be good to go.

Problem

I'm just getting my feet wet with the Ninject.Mvc3 NuGet package, and I'm wondering about how long the created objects last. `InRequestScope` is pretty each to understand: each object created in this scope lives as long as the webserver is handling a particular web request. (To be pedantic, the objects live as long as the `HttpContext.Current` object does) But how long so the `InSingletonScope` objects last? The documentation says as long as the Ninject Kernel itself does--which is wrapped up the the `NinjectWebCommon` static class. The best guess I've made so far is that the kernel lives as long as the server is running the webapp--as long as the server is up, until the app is manually restarted in IIS or updated, the objects are in scope. I'm curious because I'm tempted to have some Data Accessors containing read-only data dictionaries as Singleton Scope, and I'm wondering if this is a good idea, or a memory leak in planning.

Original source