good, Few points to add 1. a.out (the executable) has not just the text but also data segments (initialised) and bss (uninitialised) sections 2. argc and argv should be in the same stack frame of main as these are arguments to it. 3. stack and heap don't merge into one another as the OS ensures they don't cross the thresholds.
The stack is a constant size pre-allocated with something along the lines of 1MB. It appears BEFORE the heap in memory, not after it, and the heap can grow as needed (which should be upwards in the diagram) as more memory is allocated. The stack cannot grow, but rather the pointer into where to push/pop values to/from the stack changes as you traverse function calls. If the stack size is exceeded (e.g. 1 MB is used) then the program will crash due to a stack overflow.
U beautifully explained each one... What I feel missed here is.. the parameters and arguments.. If you can reply me.. Then please comment out answer for the above one... Thanks for your efforts.. Keep going bro!
The explanation is awesome indeed, but i have a query. As you have mentioned global initialized and uninitialized variable will get memory at respective area before runtime, and at runtime only stack is being created and after that only local variables get memory allocation in stack. My query is before runtime or before main program gets memory in stack, where these local variable are stored or in other way where from these local variable get pushed to this stack segment.
Some basic questions 1) who will create all these sections 2) what is the use of uninitialized Variables segment (.bss) 3) where is static uninitialized local variables stored.
ans.1)execution of c program is one of process known to OS (Operating System) so process demand for this doing section service to OS then OS will call to something call 'System call' which actually do this section ....System call is nothing but a predefined function or program of OS ..... 2) kernel (heart of OS) initialized uninitialized variable to zero ....so kernel do this for variable which are in this section 3) if static variable uninitialized or initialized to zero then it is in uninitialized variable section (uninitialized data segment ) ....and if initialized with some value other then zero then in initialized variable section((initialized data segment ))
Sorry to say, This Presenter is providing WRONG INFORMATION. Mr amitkeerti have you ever thought how, a program only outputs a.out, And If it sits completely in Code(text) segment then how other segments gets information. I don't think complier stores information each program at it's End. a.out exe has complete information, it does not sits in Text(code Segment). What the Correct thing is this: When we compile a program, a.out is created which has following segments(a.out has segments) 1. .text segment: Stores machine executable code of program (THIS GOES TO TEXT SEGMENT) 2. .rodata: Stores ReadOnly(RO) data, format string, printf, jump to switch 3. .data: Init global variables(THESE GOES TO DATA SEGMENT) 4. .bss: Unit global variables (THESE GOES TO DATA SEGMENT) 5. .symtab : (symbol table) 6. .reltext: location of text sections which needed to be combined with other .obj files 7. .reldata: Relocation information of global variables 8. .debug: Debugging information for variables, globals, typedef, when compiler is given -g option. 9. line: mapping between line number of C code and machine code 10. .strtab: String table for debug and symbol table. Thanks
What? The instructions (that are to be executed) for a program are stored in the .text section. So every operation and function call etc. exists in .text, and the variables it refers to are stored in .data etc. The compiler places things where they belong, and the instructions in the .text segment refer to addresses of the .data etc. segments. I believe.
if static variable uninitialized or initialized to zero then it is in uninitialized variable section (uninitialized data segment ) ....and if initialized with some value other then zero then in initialized variable section((initialized data segment ))
can any1 tell me what exactly data the HEAP segment contains ???? I knew that STACK contains all the FUNCTION var. BUT then what does HEAP contains ???? ***** NEED THE CORRECT ASNWER PLSSS ******* ****** ANY PERSON WITH THE RIGHT INFORMATION PLSS HELP ME ********
good, Few points to add
1. a.out (the executable) has not just the text but also data segments (initialised) and bss (uninitialised) sections
2. argc and argv should be in the same stack frame of main as these are arguments to it.
3. stack and heap don't merge into one another as the OS ensures they don't cross the thresholds.
Very excellent explanation with animation. Thanks a lot.
The stack is a constant size pre-allocated with something along the lines of 1MB. It appears BEFORE the heap in memory, not after it, and the heap can grow as needed (which should be upwards in the diagram) as more memory is allocated. The stack cannot grow, but rather the pointer into where to push/pop values to/from the stack changes as you traverse function calls. If the stack size is exceeded (e.g. 1 MB is used) then the program will crash due to a stack overflow.
Unmm, Thanks 🙏.
Best memory visualization I have seen on youtube :)
love those funky transitions
Very good and funny videos bring a great sense of entertainment!
U beautifully explained each one... What I feel missed here is.. the parameters and arguments.. If you can reply me.. Then please comment out answer for the above one... Thanks for your efforts.. Keep going bro!
because of the animation it understand good, also explanation is good
Really liked the video; very informative, thanks!!
amazing video!
Thank you . best one i have watched
Thanks, what about environment variables?
Thank you for posting this. Great video!
Awesome demonstration!
Can you explain the same by taking structure as example
The explanation is awesome indeed, but i have a query. As you have mentioned global initialized and uninitialized variable will get memory at respective area before runtime, and at runtime only stack is being created and after that only local variables get memory allocation in stack. My query is before runtime or before main program gets memory in stack, where these local variable are stored or in other way where from these local variable get pushed to this stack segment.
Because the compiler starts the process from the main func itself , so there is no variable which is initialized or stored before run time .
Excellent way to demonstrate this memory layout.... very nice good job :)
Excellent Video!!
awesome explanation via animation
Thank you very much.
thanks for posting Amit sir
whe re the constant and volatile variable will be stored ?
ultimate sir awaesome vid i ve ever seen
Sir you forgot to return a value to a func(). But I kinda understand how it works now. Ty
Really helpful...thanks so much
thank u , u made my day
Nice article!
thank you bro
superliked this video cleared all doubts and confusion...
Where does functions get stored in memory ?
Good one..
Some basic questions
1) who will create all these sections
2) what is the use of uninitialized Variables segment (.bss)
3) where is static uninitialized local variables stored.
ans.1)execution of c program is one of process known to OS (Operating System) so process demand for this doing section service to OS then OS will call to something call 'System call' which actually do this section ....System call is nothing but a predefined function or program of OS .....
2) kernel (heart of OS) initialized uninitialized variable to zero ....so kernel do this for variable which are in this section
3) if static variable uninitialized or initialized to zero then it is in uninitialized variable section (uninitialized data segment ) ....and if initialized with some value other then zero then in initialized variable section((initialized data segment ))
Many Thanks Brother :)
What do we call as "Memory here" is it the RAM
thank u very much sir....
Thanks man, that was actually pretty helpfull !
thanks man..............
gud one !
thank you sir... :-)
C on a DEBUG lowbudget ASICS or anything ELSE what is a OPERATIONsystem means GUI - terminal TTY
Very cool!! (;
Sorry to say, This Presenter is providing WRONG INFORMATION.
Mr amitkeerti have you ever thought how, a program only outputs a.out, And If it sits completely in Code(text) segment then how other segments gets information. I don't think complier stores information each program at it's End.
a.out exe has complete information, it does not sits in Text(code Segment).
What the Correct thing is this:
When we compile a program, a.out is created which has following segments(a.out has segments)
1. .text segment: Stores machine executable code of program (THIS GOES TO TEXT SEGMENT)
2. .rodata: Stores ReadOnly(RO) data, format string, printf, jump to switch
3. .data: Init global variables(THESE GOES TO DATA SEGMENT)
4. .bss: Unit global variables (THESE GOES TO DATA SEGMENT)
5. .symtab : (symbol table)
6. .reltext: location of text sections which needed to be combined with other .obj files
7. .reldata: Relocation information of global variables
8. .debug: Debugging information for variables, globals, typedef, when compiler is given -g option.
9. line: mapping between line number of C code and machine code
10. .strtab: String table for debug and symbol table.
Thanks
What? The instructions (that are to be executed) for a program are stored in the .text section. So every operation and function call etc. exists in .text, and the variables it refers to are stored in .data etc. The compiler places things where they belong, and the instructions in the .text segment refer to addresses of the .data etc. segments. I believe.
Nice information. sir please recommend a book or website where I can read to these things related to memory layout of C program.
where static variables resides ?
if static variable uninitialized or initialized to zero then it is in uninitialized variable section (uninitialized data segment ) ....and if initialized with some value other then zero then in initialized variable section((initialized data segment ))
can any1 tell me what exactly data the HEAP segment contains ???? I knew that STACK contains all the FUNCTION var.
BUT then what does HEAP contains ????
***** NEED THE CORRECT ASNWER PLSSS *******
****** ANY PERSON WITH THE RIGHT INFORMATION PLSS HELP ME ********
Foggoty stuff..
thank u very much sir..'