Your analogy is correct. The data in memory doesn’t disappear or anything like that; the values may indeed still be there after a free()
, though attempting to read from freed memory is undefined behaviour.
More Related Contents:
- Difference between static memory allocation and dynamic memory allocation
- How do free and malloc work in C?
- How much memory would be freed if pointer is changed in C?
- Using Dynamic Memory allocation for arrays
- If free() knows the length of my array, why can’t I ask for it in my own code?
- dynamic allocating array of arrays in C
- dynamic allocation/deallocation of 2D & 3D arrays
- Why exactly should I not call free() on variables not allocated by malloc()?
- How to avoid long chain of free’s (or deletes) after every error check in C?
- Where do malloc() and free() store allocated sizes and addresses?
- whats the difference between dynamic memory allocation and normal memory allocation?
- Write a C program to swap content of memory blocks of size 32 bytes
- How does free know how much to free?
- How are multi-dimensional arrays formatted in memory?
- Does free(ptr) where ptr is NULL corrupt memory?
- When and why to use malloc?
- Should I free memory before exit?
- Sharing memory between two processes (C, Windows)
- In C, do braces act as a stack frame?
- What is a contiguous memory block?
- L1 memory bandwidth: 50% drop in efficiency using addresses which differ by 4096+64 bytes
- Can I rely on malloc returning NULL?
- Unable to free const pointers in C
- Why does “memset(arr, -1, sizeof(arr)/sizeof(int))” not clear an integer array to -1?
- C: pointer to array of pointers to structures (allocation/deallocation issues)
- Problem usage memory in C
- How are we able to access the pointer after deallocating the memory?
- C Memory Management
- How to assign pointer address manually in C programming language?
- How to check heap size for a process on Linux