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 is the difference between Paste and Paste Special Option in Excel?
Paste: Paste all values, formats, formulas, comments, etc. Paste special: Paste with option, only values, only values, only formats, etc or all.
Vijayalakshmi G M
How much of ADF Faces we should know to effectively work in Oracle ADF? I am a beginner and looking for some guidance and training on working on projects on Fusion Apps.
Basics is enough, plus it depends on project. Creating a page, navigation using TFs, commit an operation etc. and knowledge on layout components is a big plus. Best part of ADF is ADF BC feature.
Jalil
0 0
6
what are the languages used to develop an android application?
Java Programming language is used by more than 95% of the developers. Tools: 1. Eclipse + Android SDK 2. Android Studio (by Google)
Raghi
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
C machine independent Programming Language? C is portable . Means What?
It can work on various hardware configuration . C doesnt require mandatory or same set of hardware to run program. A program can written on one comp. And can run on other comp.(machine)
Shiva

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

Ask a Question

Related Lessons

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

The ABCs Of Success For A Software Developer
“There is more to know for career advancement rather than focusing on codes and its challenges to become a successful developer”. A developer is the one who creates software application by...

Software Development Training In Jaipur
Satyam Web Solution provides website designing &development and software designing &development training in Jaipur for various stream’s students. MCA 6 month Industrial Training/Internship B....

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...

How Motivation Affects Learning and Behavior
Motivation directs behavior toward particular goals. Motivation leads to increased effort and energy. Motivation increases the amount of effort and energy that learners expend in activities directly...

Recommended Articles

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 >

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 >

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 it was the Internet Era of 90s or the Big Data Era of today, Information Technology (IT) has given birth to several lucrative career options for many. Though there will not be a “significant" increase in demand for IT professionals in 2014 as compared to 2013, a “steady” demand for IT professionals is rest assured...

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