J
Jack Klein
[snips]
I think you are misunderstanding what freeing immediately actually
means. In fact the standard has nothing to say about when it is freed
and it could mean many things in many systems. I would guess that free
would remove the memory from the allocated list and add it to the free
list, at a minimum. This has to be done. Whether it also returns the
memory to the OS, i.e., shrinks the data segment of the process, is
totally implementation specific.
Is it? I see nothing whatsoever in the definition of free which allows
for any implementation-defined behaviour; its behaviour, quite the
contrary, is absolutely and clearly defined, and *does not permit*
handing the memory back to the OS.
Chapter and verse, please, I insist. What wording in the C standard
prohibits free() from returning memory to the operating system?
If you can find "implementation defined" in the definition of free, in a
manner which would allow the behaviour you describe, please quote it; I
cannot find it anywhere.
It is not implementation-defined, it is indeed unspecified. The one
and only statement in the standard that speaks about memory
deallocated by free() is (in C99) the first sentence of paragraph 2 of
7.20.3.2: "The free function causes the space pointed to by ptr to be
deallocated, that is, made available for further allocation."
What, in this wording, says that the space must be available for
further allocation by the program that free'd it?
What, in this wording, prohibits the implementation, which includes
the host OS in a hosted environment, from making that memory space
available to another process/program/component?
Since the standard does not define or constrain "further allocation",
how can you claim it forbids the second example?
--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html