Series: Subject: Topic:
Question: 322 of 828

Difference between program memory, data memory, stack memory and heap memory?

Asked by: Interview Candidate | Asked on: Jun 8th, 2007
Showing Answers 1 - 5 of 5 Answers

Answered On : Jun 11th, 2007

View all answers by neverd

Program memory includes data memory, stack memory and heap memory and code memory

Login to rate this answer.
Sridhar V

Answered On : Jul 9th, 2007

When the program is compiled and linked different parts of the program is organised in seperate segments. That is our code will be in one segment code means the instructions to be executed this is called as code segment or program memory this is usually readonly. Then there are datas which on which the code operates,these datas get stored in a segment called data segment. Stack memory is a part of programs memory which will be used as stack in case of function calls to store the IP and parameters variables of the current function. The three types of memory specified above are owned by the corresponding process or program the linker will give info abt where to store which data to the loader, based on these infos loader will load the corresponding image i.e executable in the memory.Heap memory is the memory which is not owned by the process. OS has set of pages of memory which can be allocated to the process when a process requests for extra memory, these requests are done by the malloc and calloc function calls. This memory is allocated when the program is running and according to the current condition of the process i.e allocated dynamically thats y this is called as dynamic allocation.I have used words program and process invariably. Because a program needs physical primary memory when it gets executed and a program under execution is a process, Hope this explanation is clear.

Yes  1 User has rated as useful.
Login to rate this answer.

Kindly see the memory diagram for C programsLow Memory__________________________CODE MEMORY                             |   (CODE SEGMENT)__________________________|INITIALIZED MEMORY                   |   Initialized adn unintiallized static and ------------------------------------------|   global variables stored hereUNINTIALIZED MEMORY (BSS)      |    (DATA SEGMENT)__________________________|HEAP                                            |    Memory allocated with calloc and malloc__________________________|    stored here                       ||                       /                        /____________||_____________STACK(STACK SEGMENT)              |          Initialized and unintiallized automatic __________________________|           variables store hereHigh Memoryarrow indiacates the growth of memory address as the memory is filledThis diagram shows the use of the CS, DS, SS, ES with regards Aravind Kumar Singh

Login to rate this answer.
mukesh patil

Answered On : Aug 4th, 2014

Data memory = where you place your variables. You can read and write values.

Program memory = where the application is stored. Some chips allows parts of the program memory to be modified in blocks (segments), but you cant store variables in the program memory. It is normally possible to store constants - i.e. initialized variables that you do not change - in the program memory.

Your PC also has data memory and program memory. But the program memory is very small in the PC - it is just for storage of the BIOS - the boot messages you see when the PC boots, and (often, but not always) the configuration pages where you define if you have a floppy installed, if the computer should support a USB keyboard etc.

Login to rate this answer.
Amol Patil

Answered On : Aug 4th, 2014

Program memory:where place your variable,you can read and write values

data memory:where tee application is stored some chips allows part of the program memory to be modified in block
,but you cant store a variable in the program memory.means initilize variable is not change in program memory.

Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions



twitter fb Linkedin GPlus RSS


Interview Question

 Ask Interview Question?


Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.