Dynamic Memory Allocation in DSA
basics of dynamic memory allocations and how memory can be allocated dynamically- using functions and everything with the help of programs. The Academy is conducting a combat on 6th of March at 11am and it is a live test. Memory would not be allocated at compile time, but see memory would be allocated in compile time. Memory would be located at run time and memory is fixed like for example, in a traditional compiler it's two bytes and in some machines it depends on what integer takes two bytes. It is fixed that at compile time only that how many bytes would be allocated into 4- that is 20 bytes. 1, 2, 3, 4, 5 right five elements can store and 20 bytes are allocated this way. Suppose suppose you are using only three values- only three elements- so these two spaces these four and four eight bytes are wasted memory. Memory can be allocated and deallocated at runtime, depending on your programming needs. The memory would be located at runtime and accessed using runtime variables. You can't increase or decrease the size of a located memory, but memory would be located from the heap only. This part is still being worked on, so please stay tuned for a separate video on this subject. This memory and the base address this pointer would contain what base address of this block right using this pointer only we can store some value we can access the value from this block and all another thing which is very important is it's your responsibility to free this memory after you are done with this memory. Once you have used this memory and you're done, you don't need it anymore in your program. This memory during the execution of the program after exit from the program would be freed, but during execution you can not free it so memory can not be reused. This is one more you can say drawback of small memory allocation. I hope you can write these you know points according to yourself in your language only right so now I guess the basics of dynamic memory allocation is clear.
Written for
- Institution
- MAKAUT University
- Course
- Data Structure and Algorithm
Document information
- Uploaded on
- March 19, 2023
- Number of pages
- 7
- Written in
- 2022/2023
- Type
- Class notes
- Professor(s)
- Nil
- Contains
- All classes
Subjects
-
dynamic memory allocation