Size of a variable | Sololearn: Learn to code for FREE!


Size of a variable

when I declare a variable it takes a part from the memory which memory they mean is it Ram or ssd or what (I am too ignorant 😓😭)

8/26/2018 9:37:36 AM


5 Answers

New Answer


The stack is generally used to store all of the stuff you create at compile-time such as local variables, the parameters you pass in a function and more... The heap is mainly used to store all of the stuff you create at run time, there is always a variable that points to the dynamic space and this is what we call a "pointer". More:


You're just a beginner, not ignorant, this is a legit question, LOL. Basically the allocated space depends on the variable itself, it can be stored mainly in CPU registers or into the stack. The stack is stored in computer RAM. CPU registers are way faster but limited. Note. There's also the heap where it's stored the dynamically created space, however the variable that points to that space is always located into the stack.


what is the defferent between stack and heap and what is the realtive between them and Ram


thanks for helping Maz


Java and JS =???