Is stack memory only for pointers and heap for objects? <p>Firstly, I'm currently working in C# and I've been reading up on memory management. So far, I've read through some great answers on stack overflow explaining the difference between stack memory and the managed heap memory. The majority of the answers state that by declaring:<br> <code>int x = 5</code>, you're allocating enough memory for the type of <code>x</code> within the stack memory.<br><br> I understand how this works as well as the scope of it, however when I read the explanation of heap memory, it confused me.<br><br> If you're saying <code>int x = 5</code>, since <code>int</code> is an alias of <code>System.Int32</code>, wouldn't <code>x</code> technically be a pointer to a new instance of the <code>System.Int32</code> struct? And if so, wouldn't it then be stored in the heap memory since that's used for instance objects.<br><br> In <a href="http://www.codeproject.com/Articles/76153/Six-important-NET-concepts-Stack-heap-value-types" rel="nofollow">this</a> tutorial, it states (for the line <code>class1 cls1 = new class1()</code>): <blockquote>... creates a pointer on the stack and the actual object is stored in a different type of memory location called ‘Heap’.</blockquote><br>By this logic, isn't everything stored on the heap and only pointers stored on the stack? Examples being new instances of <code>System.String</code>, <code>System.Int64</code>, <code>System.Boolean</code>, <code>System.Decimal</code> etc.<br><br> I thought I understood it, however clearly I don't, so I would appreciate someone explaining whether the stack is only for pointers or which part I've misinterpreted. Thanks in advance.</p>