Re: kernel 2.6.13 - space not freed to kernel

From: linux-os (Dick Johnson)
Date: Fri Sep 02 2005 - 14:29:54 EST



On Fri, 2 Sep 2005 tachades@xxxxxxxxxxxx wrote:

> i have a program that all it does is to allocate memory up until consume 1GB of
> free resources. but when i delete it, it seemed that the space is not free to
> kernel, (notice this by looking at "top" or meminfo, as well as debug messages
> prinf the memory info. using sysinfo (system call). this happens on mainline
> kernel 2.6.13 but not on other Redhat distros (RHEL3/RHEL4).
>
> so it seemed that on mainline 2.6.13, when the userprocess allocate mem and free
> it mem, the freed memory is not returned back to the kernel... is this a
> possible bug????
>
>
> Please Observe this test program:
> Assumption: in main() the space (units in KB) to allocate is 1GB, if you machine
> has less than that use lower space value- 100MB (to be left to avoid oom
> killer).
> Idea: allocate using a linked list to as many nodes as it required to filled up
> 1GB or less of address space
>
> Result: on RHEL3 or 4, after the program allocate nodes, and then deallocate it,
> sysinfo indicate the memory that were freed are returned to the kernel.
> on 2.6.13, after the proram allocate nodes, and then deallocate it, sysinfo give
> the free{ram+swap} to be about the same as it was after the node finish
> allocating, seemed like the freed nodes address space were not returned to the
> kernel
>
> any ideaS?
[SNIPPED strange program]

The program allocates memory. It does this by either setting the break
address or mapping memory. It depends upon the malloc() that your
'C' runtime library uses.

The usual malloc() never resets the break address or remaps memory
because it is an expensive operation. This means that when new
data space needs to be allocated, malloc() doesn't have to get
anything from the kernel because it already has, probably, all
that it needs.

The only way memory will be 'returned' is when your program
calls exit() or otherwise ceases to exist.

FYI, this isn't a kernel issue. Even if it was broken it's
not a kernel issue because the kernel doesn't care what a
user-mode program does with the address-space it has allocated.
It's address-space that it hasn't allocated that it cares
about. That gives you a seg-fault.

Cheers,
Dick Johnson
Penguin : Linux version 2.6.13 on an i686 machine (5589.54 BogoMips).
Warning : 98.36% of all statistics are fiction.
.
I apologize for the following. I tried to kill it with the above dot :

****************************************************************
The information transmitted in this message is confidential and may be privileged. Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited. If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to DeliveryErrors@xxxxxxxxxxxx - and destroy all copies of this information, including any attachments, without reading or disclosing them.

Thank you.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/