if we use singleton pattern in our web application, when free the specified memory that allocated to our class?
if we use singleton pattern in our web application, when free the specified memory
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Technical answer: The memory is freed when the AppDomain is unloaded or the process is shut down.
Better answer: The memory is freed whenever the GC decides to free it. You don’t know and aren’t supposed to care. If your Singleton is tracking unmanaged resources (i.e. file handles, GDI handles, anything other than memory), and you need to release them at any time whatsoever while your application is still “running”, then the Singleton needs to provide the necessary methods to do so.