Reputation: 143
I am storing a list in Singlton class I wan't to know the life time of singleton object. I know IIS Reset Or App pool recycle(after day or so of inactivity) it will destroy the object.
Does it gets destroyed if sever has heavy load? or any other condition.
Please help
Thanks
Upvotes: 3
Views: 1784
Reputation: 7449
Its lifetime depends on when you initialize the Singleton, but once you did, it'll stay alive (assuming you have an instance of the singleton class in a static member) until the thread corresponding to the application pool is dropped, because of inactivity, the application pool being restarted/stopped/recycled, or anything that causes the application pool to recycle or stop basically.
If you initialize the Singleton in the Application_Start
event of the Global.asax
you can be sure your Singleton will be available at any time in your application.
Upvotes: 2