I read an article which confused me about memory allocation, which stated:
Singleton objects are stored on the heap while static classes are stored on the stack.
But in some Stackoverflow questions, such as
How is memory allocated for a static variable?
It was described like
Static variables are stored on the heap, regardless of whether they are declared as a reference type or a value type. There is only one slot in total no matter how many instances are created.
So I am confused with stack or heap storage for static classes. How is memory allocated for a static class and why? How is memory allocated for singleton class?