in Technology by
What is static memory allocation and dynamic memory allocation?

1 Answer

0 votes
by

According to C standard, there are four storage duration, static, thread (C11), automatic, and allocated. The storage duration determines the lifetime of the object.

The static memory allocation:

Static Allocation means, an object has external or internal linkage or declared with static storage-class. It’s initialized only once, prior to program startup and its lifetime is throughout the execution of the program. A global and static variable is an example of static memory allocation.

The dynamic memory allocation:

In C language, there are a lot of library functions (malloc, calloc, or realloc,..) which are used to allocate memory dynamically. One of the problems with dynamically allocated memory is that it is not destroyed by the compiler itself that means it is the responsibility of the user to deallocate the allocated memory.

When we allocate the memory using the memory management function, they return a pointer to the allocated memory block and the returned pointer is pointing to the beginning address of the memory block. If there is no space available, these functions return a null pointer.

Related questions

0 votes
    How is the dynamic memory allocation in 1D array in C?...
asked Jan 24, 2021 in Technology by JackTerrance
0 votes
    Distinguish between malloc() & calloc() memory allocation?...
asked Jan 17, 2021 in Technology by JackTerrance
+1 vote
    Distinguish between malloc() & calloc() memory allocation....
asked Nov 9, 2020 in Technology by JackTerrance
0 votes
    In Visual Studio, we've all had "baadf00d", have seen seen "CC" and "CD" when inspecting ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 13, 2022 in Education by JackTerrance
0 votes
    How do you differentiate dynamic cache from static cache?...
asked Mar 26, 2021 in Technology by JackTerrance
0 votes
    What is the difference between Static and Dynamic resources?...
asked Apr 9, 2021 in Education by JackTerrance
0 votes
0 votes
    Sometimes, when dynamic body moving and collide static body, dynamic stuck, and stopping. http://imageshack. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 27, 2022 in Education by JackTerrance
0 votes
    Which built-in library function can be used to re-size the allocated dynamic memory?...
asked Jan 18, 2021 in Technology by JackTerrance
0 votes
    Which function can be used to release the dynamic allocated memory in C?...
asked Nov 9, 2020 in Technology by JackTerrance
+1 vote
    Which built-in library function can be used to re-size the allocated dynamic memory in C-Programming?...
asked Nov 9, 2020 in Technology by JackTerrance
0 votes
    What is Latent Dirichlet Allocation (LDA)?...
asked Mar 11, 2021 in Technology by JackTerrance
+1 vote
    Default Private IP address allocation method is _________....
asked Oct 20, 2020 in Technology by JackTerrance
0 votes
    A ______ file system is software that enables multiple computers to share file storage while maintaining ... Storage Structure in portion Transactions of Database Management...
asked Oct 10, 2021 in Education by JackTerrance
0 votes
    ________ is the smallest unit of allocation in an Oracle database. (a) Database (b) Instance (c) ... Answers, Database Interview Questions and Answers for Freshers and Experience...
asked Oct 11, 2021 in Education by JackTerrance
...