Possible Duplicate:
Whether variable name in any programming language takes memory space
I was just reading about memory allocation, and can’t help wonder this question:
Do both
int x = 4;
and
int this_is_really_really_long_name_for_an_integer_variable = 4;
occupy same amount of memory (the total memory occupied by the variable. not just sizeof(int))
I understand that this question is related to ‘programming languages and compiler construction’. But, I haven’t got to study it 🙁
In general they occupy the same amount of space, i.e.
sizeof(int). However, one could argue that when building an object file with additional symbols for debugging the ratio is different. The amount of data which the variable stores does not change but the debugging symbols occupy more space in case of the longer variable name. Consider a following example.The difference in size is exactly the difference of lengths of variables’ names.
From a run-time efficiency and memory usage point of view it does not matter, though.