[Am-info] Why does NT fail to release allocated memory?

Eric Lee Green elgreen@iname.com
Sat, 8 Jan 2000 16:12:49 -0700


On Sat, 08 Jan 2000, Lewis A. Mettler wrote:
> This is not necessarily the case.  However, if NT does not release all
> memory back to the available pool until program termination (regardless
> if free() is called or not), NT is poorly designed and can no longer be
> used.

Note that Unix displays the exact same behavior. The "free()" call in most libc
implementations merely puts the freed block of memory into an internal "free"
list for use by future malloc() calls rather than return it to the operating
system. This is due to efficiency -- most programs use a fairly constant amount
of memory, and constantly calling the kernel to handle routine malloc/free
would be ridiculously expensive. 

I would also question how you are measuring allocated memory. Note that many
operating systems will use memory as disk caches. Thus the amount of free
memory rarely is the same after program exit as it was before the program was
executed. This is a common question in the Linux world by Linux newbies -- "I
ran a program, and now 'free' shows that all my memory is being used!".  In
addition, lingering sockets and other such internal kernel issues can result in
memory being used temporarily.

This is not to say that NT doesn't leak memory -- my brother has a program that
on NT 4 SP2 will consistently leak memory out of the network stack, for
example. It's just saying that the behavior you're complaining about is normal
behavior for most operating systems, and is unrelated to the leaking problem.

-- 
Eric Lee Green   e_l_green@hotmail.com
  http://members.tripod.com/e_l_green/