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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With