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

Hi, I am a website designer. I used to convert psd into html and also use some basic Javascript for the functioning part. Now I want to work as a developer, so I want to know the scope of UI Development. What language should I need to focus on to get properly into development for the long term?

First of all the role of a UI developer is that of a combination of a web designer and a web developer. The language skills required for a UI developer are front-end web development languages like HTML,...
Mudita

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

Ask a Question

Related Lessons

Programming Practice Technique
Any Programming Language required an Algorithm. Algorithm - It is the finite set of instructions in which each and every instruction has the meaning, instructions are not ambiguous and all the instructions...

Focus on Fundamentals
It is very important to focus on fundamentals of any subject one is interested to gain command over that subject. If one learns and understand the fundamentals throughly, it is easy to grasp the advance...

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

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

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

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