UrbanPro

Learn Computer Software from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

How does memory allocation is occurred during executing a simple C program .??

Asked by Last Modified  

Follow 0
Answer

Please enter your answer

Math Mad

Memory allocation is of types: Static Memory Allocation and Dynamic Memory allocation. Static is a fixed one and is allocated once during compile time, whereas dynamic memory is allocated during run time.
Comments

Trainer

1. Dynamic memory allocation-Runtime 2 Compile time -static
Comments

Advanced computer Software and Design as per industry standard

Segment Description Code - text segment Often referred to as the text segment, this is the area in which the executable or binary image instructions reside. For example, Linux/Unix arranges things so that multiple running instances of the same program share their code if possible. Only one copy...
read more
Segment Description Code - text segment Often referred to as the text segment, this is the area in which the executable or binary image instructions reside. For example, Linux/Unix arranges things so that multiple running instances of the same program share their code if possible. Only one copy of the instructions for the same program resides in memory at any time. The portion of the executable file containing the text segment is the text section. Initialized data – data segment Statically allocated and global data that are initialized with nonzero values live in the data segment. Each process running the same program has its own data segment. The portion of the executable file containing the data segment is the data section. Uninitialized data – bss segment BSS stands for ‘Block Started by Symbol’. Global and statically allocated data that initialized to zero by default are kept in what is called the BSS area of the process. Each process running the same program has its own BSS area. When running, the BSS, data are placed in the data segment. In the executable file, they are stored in the BSS section. For Linux/Unix the format of an executable, only variables that are initialized to a nonzero value occupy space in the executable’s disk file. Heap The heap is where dynamic memory (obtained by malloc(), calloc(), realloc() and new – C++) comes from. Everything on a heap is anonymous, thus you can only access parts of it through a pointer. As memory is allocated on the heap, the process’s address space grows. Although it is possible to give memory back to the system and shrink a process’s address space, this is almost never done because it will be allocated to other process again. Freed memory (free() and delete – C++) goes back to the heap, creating what is called holes. It is typical for the heap to grow upward. This means that successive items that are added to the heap are added at addresses that are numerically greater than previous items. It is also typical for the heap to start immediately after the BSS area of the data segment. The end of the heap is marked by a pointer known as the break. You cannot reference past the break. You can, however, move the break pointer (via brk() and sbrk() system calls) to a new position to increase the amount of heap memory available. Stack The stack segment is where local (automatic) variables are allocated. In C program, local variables are all variables declared inside the opening left curly brace of a function's body including the main() or other left curly brace that aren’t defined as static. The data is popped up or pushed into the stack following the Last In First Out (LIFO) rule. The stack holds local variables, temporary information, function parameters, return address and the like. When a function is called, a stack frame (or a procedure activation record) is created and PUSHed onto the top of the stack. This stack frame contains information such as the address from which the function was called and where to jump back to when the function is finished (return address), parameters, local variables, and any other information needed by the invoked function. The order of the information may vary by system and compiler. When a function returns, the stack frame is POPped from the stack. Typically the stack grows downward, meaning that items deeper in the call chain are at numerically lower addresses and toward the heap. read less
Comments

B.E+MBA

You need to study stacks and LIFO principle
Comments

Software Professional Trainer with 26+ years of Experience in Software Design and Development

Static memory will get allocated during compile time. Dynamic memory allocation will happen during program run time Memory segments are segregated as mentioned below. Text segment - All the source code will be stored Data Segment - Initialized data segment - Static and Global...
read more
Static memory will get allocated during compile time. Dynamic memory allocation will happen during program run time Memory segments are segregated as mentioned below. Text segment - All the source code will be stored Data Segment - Initialized data segment - Static and Global variable which are initialised Uninitialized data segment (BSS) - Static and Global variable which are uninitialised Stack - Static memory allocation for auto variable Heap - Dynamic memory allocation for pointer read less
Comments

Computer Software Training Classes

cache memory
Comments

Expert in Computer Science

Dynamic memory allocation is used to manage available memory, as memory allocation decisions are taken at run time
Comments

There are 2 types of memory allocation in c: 1. Dynamic memory allocation-Runtime 2 Compile time -static In dynamic memory allocaion your variables size will be decided on runtime. In static memory allocation variables size are fixed, so its size is decided on compile time.
Comments

C, C++, Embedded Systems Trainer

The storage class determines the part of memory where storage is allocated for an object (particularly variables and functions) and how long the storage allocation continues to exist. A scope specifies the part of the program which a variable name is visible, that is the accessibility of the variable...
read more
The storage class determines the part of memory where storage is allocated for an object (particularly variables and functions) and how long the storage allocation continues to exist. A scope specifies the part of the program which a variable name is visible, that is the accessibility of the variable by its name. In C program, there are four storage classes: automatic, register, external, and static. Keep in mind that in the hardware terms we have primary storage such as registers, cache, memory (Random Access Memory) and secondary storage such as magnetic and optical disk. read less
Comments

Lecturer Computer Applications

C language supports two kinds of memory allocation: 1 static allocation 2. dynamic allocation. static allocation is of a fixed size. It is allocated only once, when your program is started and never freed till program is running or the variable is in scope. In dynamic allocation size of required memory...
read more
C language supports two kinds of memory allocation: 1 static allocation 2. dynamic allocation. static allocation is of a fixed size. It is allocated only once, when your program is started and never freed till program is running or the variable is in scope. In dynamic allocation size of required memory depends on factors that are not known before the program runs. There are functions which we cal call to allocate memory at run-time. Example: malloc(), realloc(). Further, memory representation is of below sections: 1. Text segment 2. Initialized data segment 3. Uninitialized data segment 4. Stack 5. Heap read less
Comments

View 8 more Answers

Related Questions

What's best training institue in hyderabad to learn hadoop?
Kelly technologies as per my knowledge
Maniahatunk
Can we make 2 folders of same name in the same place without copying or without changing any script?
First go to the folder or drive where you want to make the same named file or folder. Lets assume that you are creating folder named IT Now create an another new folder and name it as IT and then press Alt+0160 from numeric keypad. That's it!
Sachin
Sir, which is the best software course to be learned for higher salary package and to settle well? As I am B.Tech in EEE branch I have no IT back ground. Please suggestion will be welcomed.
It would be great if you go for SAP in many courses of SAP u did not need to have IT background. And yes its a costlier course. But it will give you higher salary packages once you will clear the course....
Niranjan
Which online teaching software is best?
If there is one student you can prefer skype even here you get more voice clarity. @ Vinodh, If you want to share screen in Skype, Got to Menu bar --> click on call menu --> there you can see share screen...
Aditya

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

For All The New Developers
Language to use: Any language that you are learning. Interface: Web or Desktop Function: Simple calculator (9 digits + symbol) with 1 Memory storage with possible function of + - * / Error Handling...
R

Easy way to remember Java keyword.
ACCESS MODIFIER ACCESS SPECIFIER abstract, assert, const, final, native, static, strictfp, super, synchronized, this, transient, void, volatile public, private, protected, default DATA...

Rohit Deshbhratar

1 0
0

Efficient Learning Strategies
Type your notes after class Write your notes onto flashcards - Scrabble -Make posters Review flashcards while walking, at gym, etc. Dog-ear pages in the reading where you can find...

Python breaks into the top three programming languages in the Tiobe Index for the first time.
Python breaks into the top three programming languages in the Tiobe Index for the first time. The popularity of Python shows no sign of waning, with the programming language entering the top three in...

Merge Multiple PST Files into One Using PST Merge Tool
Overview of PST Merge Software The PST Merge is a software which merge multiple PST files into a single PST file. It makes sure that when PST files are merged into a new file, the original PST files should...
V

Recommended Articles

Decades back, when computers were being introduced in office premises, PPT was a new terminology that all employees tried to learn. Now PPT has made its way far away from offices and is an integral part of schools, colleges, and several other official proceedings. This is because PPT is an user-friendly computerized method...

Read full article >

Whether you are using a laptop or a desktop, the mouse surely takes up time. Imagine if you could alone manage with the keys and not have to move your hands around the mouse? That would have been faster and so much time-saving. For example, Control + Z for undo or Control + Y for redo, definitely saves time when we are...

Read full article >

Software Development has been one of the most popular career trends since years. The reason behind this is the fact that software are being used almost everywhere today.  In all of our lives, from the morning’s alarm clock to the coffee maker, car, mobile phone, computer, ATM and in almost everything we use in our daily...

Read full article >

MCTS Certification in India The Microsoft Certified Technology Specialist or MCTS certification is suited for professionals who want to get into profession of implementing, building, troubleshooting, and debugging a particular Microsoft technology. The MCTS certification can give you a clear edge over others to showcase...

Read full article >

Looking for Computer Software Classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for Computer Software Classes?

The best tutors for Computer Software Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Computer Software with the Best Tutors

The best Tutors for Computer Software Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more