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

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
How to create dynamic charts in Excel?
If the source table can grow automatically to include the data in the Chart automatically, then that is called a DYNAMIC CHART. Say, if you have included Jan to Apr month values in Chart and later try...
Vijayalakshmi G M
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
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

History of SQL server
In 1988, Microsoft released its first version of SQL Server. It was designed for the OS/2 platform and was developed jointly by Microsoft and Sybase. During the early 1990s, Microsoft began to develop...

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

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

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

Big Data Hadoop Training
What is Big Data? Big data means really a big data, it is a collection of large datasets that cannot be processed using traditional computing techniques. Big data is not merely a data, rather it has become...

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