According to Linux programmers manual:

brk() and sbrk() change the location of the program break, which
defines the end of the process’s data segment.

What does the data segment mean over here? Is it just the data segment or data, BSS, and heap combined?

According to wiki Data segment:

Sometimes the data, BSS, and heap areas are collectively referred to as the “data segment”.

I see no reason for changing the size of just the data segment. If it is data, BSS and heap collectively then it makes sense as heap will get more space.

Which brings me to my second question. In all the articles I read so far, author says that heap grows upward and stack grows downward. But what they do not explain is what happens when heap occupies all the space between heap and stack?

enter image description here

8 Answers
8

Leave a Reply

Your email address will not be published. Required fields are marked *