Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is a singleton shared through a different applications?

Tags:

c#

singleton

I am wondering: if I create a singleton class with a private constructor and one static method which will return instance of this class and I put it to assembly, what will happen if I access this instance from two different applications?

Do the applications will always share the same instance of the singleton?

And if both of those applications unload from the memory the instance will be freed as well?

Thanks.

like image 953
Wodzu Avatar asked Oct 11 '10 07:10

Wodzu


1 Answers

Two different applications will not share the object, no. They will of course share the exact same code for the object, since they are loading the same assembly, but they will each have their own single copy, in their own address space.

In fact - even the same application, running twice, will not share the actual Singleton instance between them.

like image 59
Andrew Barber Avatar answered Sep 25 '22 02:09

Andrew Barber