What is Data Segment memory in a program? Is it different from stack memory? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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?

27th Sep 2018, 6:26 AM
Sonic
Sonic - avatar
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.
27th Sep 2018, 9:31 AM
Ross Drew
Ross Drew - avatar
+ 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.
27th Sep 2018, 7:48 AM
Sonic
Sonic - avatar
+ 12
KrOW that's a relief 😳😌
27th Sep 2018, 7:40 AM
Sonic
Sonic - avatar
+ 2
Sonic Yes 😁😁😁 but remember: more low level side you know and more skills you aquire 😉
27th Sep 2018, 7:42 AM
KrOW
KrOW - avatar
+ 1
You need to know it only for low level programming and hardly you have to take cure on scripting side
27th Sep 2018, 7:38 AM
KrOW
KrOW - avatar
0
fast
27th Sep 2018, 12:21 PM
ДиМ4иК Warface