C Memory Management ! Dynamic memory allocation

Categories: C Programming language

Here we explain dynamic memory management in C. The C programming language provides several functions for memory management and allocation.


In c two types of memory management

  1. Static memory allocation
  2. Dynamic memory allocation

Static memory allocation

Union is used to group a number of different variables together. In structure number of different variables of different data type stored in different memory places but in union different variable of different data type are store in same place.

Example

struct student
{
int rollno;
char name[50];
float salary;
};


Dynamic memory allocation

In dynamic memory management memory will be allocate at runtime. This is also known as heap memory. Some language at the run time have ability to calculate and assign the memory space at run time for an array but c can't have this feature. But in C there is some function which provide the facility to allocate and deallocate the memory. In ,Local Memory, when these function will call memory will allocate automatically and when function will exit memory will deallocated automatically . In dynamic memory allocation ,allocation of memory is explicitly requested for a particular size of block .For deallocation of memory explicitly requested.

The function through which the dynamic memory allocation and deallocation will performed are :

  • malloc()
  • calloc()
  • free()
  • realloc()

Top Blogs
C Functions ! What is a Function Published at:- Types of Function in C ! Library Function in C ! User Defined Function In C ! Function Definition Published at:- Functions that return multiple values -C Example Published at:- Functions with arguments and return values -C Examples Published at:- Functions with arguments and no return values. Published at:- Example of Function with no return type and no argument Published at:- Loops in C Published at:- Structure in C: Introduction Published at:- C Memory Management ! Dynamic memory allocation Published at:- Learn C Programming language with example Published at:- C Interview Questions And Answers Published at:- What values are printed when we run following? Published at:- C Program example: Input a number and print sum of its digits Published at:- Pointer declaration in C ,Address operator Published at:- C Language Interview Question and Answers Published at:- Benefits of C language over other programming languages Published at:- History of C Language : Introduction to C Programming Language Published at:- How does C Programming Language Work Published at:- Importance of C Programming Language Published at:- Input and Output Functions in C Published at:- Introduction to Implementation of Queue using Linked List Published at:- First C Program Published at:- Inception Of C Language Tutorial for Beginners Published at:- The C Compiler work in C language and its important Published at:- Program Structure with “Hello World” Example Published at:- C Programming Interview Questions Set 1 Published at:- C Programming Interview Questions Set 2 Published at:- C Programming Interview Questions Set 3 Published at:- C Programming Interview Questions Set 4 Published at:- C Programming Interview Questions Set 5 Published at:- C Programming Interview Questions Set 6 Published at:- C Programming Interview Questions Set 7 Published at:- C Programming Interview Questions Set 8 Published at:- C Programming Interview Questions Set 9 Published at:-
R4R.co.in Team
The content on R4R is created by expert teams.