+ 1

How does Singleton work

I know it's used for loggers but I'm not sure how it works, I would like to know when to use it and when not to use it.

18th Aug 2021, 4:43 PM
Tim
Tim - avatar
1 Resposta
+ 2
Singleton used to create single object. Suppose there is a class which is accessed by many client so every time object will be create of that class and this object will be store in heap memory. So if there are 1000 client accessing that class then 1000 objects will be store in heap memory which result would be slow performance of the system. So to avoid this we use singleton.
18th Aug 2021, 5:32 PM
A͢J
A͢J - avatar