+ 17
What is Data Segment memory in a program? Is it different from stack memory?
I know about heap memory used for dynamic memory allocation and stack memory for static memory allocation but unsure about Data Segment memory (initialised/uninitialised). Why does the programmer need to know about these? Are programmers of interpreted languages free from having to know about these types?
6 Answers
+ 5
When your code is placed in memory, you would -generally- assume that it's not going to be changed or your program will do crazy stuff. In one case, you would want your code to change and that is the space in which you store your variables. This section of your program code is called the "Data Segment". Essentially the writable part of your program, defined by your program.
The stack is an environment (computer/VM) defined area, refereed to by a Stack Pointer in a part of memory seperate from program code in which values can be placed and removed in a Last-in First-out (LIFO) fashion.
Most modern languages maintain the distinction for you, when we started back in the 80s it was a very important distinction you had to be aware of. Sometimes, it's still good to know these days. Don't let anyone tell you that you don't need to know something in this industry. *Information* Technology.
+ 15
KrOW yes, globals, static variables and constants seem to be in Data Segment; other local variables, parameters, and fixed length arrays seem to be in stack. I get the feeling this is more C/C++ specific. Maybe also Java/C#. Luckilly you don't care about these in PHP, python, Javascript, Ruby etc. At least that's my understanding from Googling around.
+ 12
KrOW that's a relief đłđ
+ 2
Sonic Yes đđđ but remember: more low level side you know and more skills you aquire đ
+ 1
You need to know it only for low level programming and hardly you have to take cure on scripting side
0
fast