
freeing malloced memory back the operating system.
Quote:
> This problem came up in a system meeting today at our company.
>The guru, whose knowledge I respect deeply, stated that gcc's
>malloc/free package does correctly return memory to the OS, but
>that many implementations (I'm most familiar with MS-DOS) do not.
gcc is not a complete C implementation. It is only a compiler, which
still uses the system supplied headers (with a few exceptions) and
libraries. Your guru must have been talking about glibc, which is a
separate "product".
The big question is whether a free() implementation which returns the
memory to the OS is "correct" on a multitasking system. I argued, in a
previous discussion on this subject, that such an implementation is
broken, based on this quote from the standard:
The free function causes the space pointed to by ptr to be
deallocated, that is, made available for further allocation.
My argument was that if the memory is returned to the OS, the OS might
give it to a different process and it won't be available to the original
one "for further allocation". Some people disagreed with my interpretation.
Quote:
> However, I see that you are using linux, and I had been under
>the impression that linux uses gcc. Hmmm.
See my comment about gcc above.
Dan
--
Dan Pop
CERN, CN Division
Mail: CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland