I read this question and answer: How do malloc () and free () work?
A friend asked me how I can be sure that I worked free. I replied that if this does not work, then the OS is likely to crash, and it will not matter any longer.
But I'm more interested in the nature of the answer to this question. As soon as I free my memory, how can I be sure that it has been freed? Am I just assuming this happened? This is a purely theoretical question without the actual code behind it, and basically when I think about what I decided “well, it doesn't matter anyway”, but I'm not sure about this answer.
For example, if memory is a problem, and I want to make sure that a large free structure was freed up after a free call, otherwise I will try to clear again, is there any way to do this?
Edit: To those who answered my question, he answered: The free () function in C does not work for me.
The answer provided simply says that I "can’t check if it works free()." I am trying to understand why this is not possible. What nature is free.
Edit2: After reading the answers I received, it seems that the answer I gave to my friend is accepted that "it just works."
source
share