Concept
How do you deallocate dynamically allocated arrays?
ComputerScienceOne / Using Arrays with Functions
"Once dynamically allocated memory is no longer needed, we should release it so that it can be reused by the program or the operating system. The free() function in the standard library does this for us. All we need to do is provide the pointer to free() and it deallocates the memory block.\n\n1 free(arr);\n\nOnce freed, accessing old memory pointed to by the arr pointer is undefined behavior and may lead to unexpected or fatal results."
Related Ideas
- How does Java dynamically allocate and release memory for arrays?ComputerScienceOne · Using Arrays with Methods
- How do you use and validate a dynamically allocated array?ComputerScienceOne · Dynamic Memory
- How does malloc() allocate memory for a dynamic array?ComputerScienceOne · Dynamic Memory
- How does Java dynamically allocate and manage memory for arrays?ComputerScienceOne · Dynamic Memory
- What are arrays used for?ComputerScienceOne · Arrays, Collections & Dynamic