Re: 'disposable' dirty pages [was: Out Of Memory in v. 2.1]

Ely Wilson (plexus@ionet.net)
Thu, 8 Oct 1998 12:08:01 -0500 (CDT)


> > | Hmm, I'm wondering. I haev this application, it allocates 10 blocks each
> > | 1 megs in size. Then I free() 5 of those blocks, but the program is still
> > | eating 10 megs of memory.
> > | Is this right?
> >
> > Well, it's "normal". UNIX processes generally only grow.
> >
> > malloc()s don't need to call the OS (via brk()) to get more memory -
> > it can reuse those 5 free megs.
> >
> > There are costs, of course:
> > So it's not as bad as you fear, but it's not totally free, either.
>
> glibc seems to give back memory. Here I allocate some memory, I don't
>
> When the buffers are freed. the memory usage goes down. This runs all
> night without any problems or any 'creeping' memory usage.
>
> #include <malloc.h>
>
> main()
> {
> for(;;)
> {
> for(i=0; i< PTRS; i++)
> if((p[i] = (char *) malloc(SIZE * sizeof(char))) == NULL)
> free(p[i]);

basically, you are recycling memory, the memory i staken of the programs
heap but never actually freed. I can see where this might be of value,
but what about long running and often forking processes that DON'T need to
keep that 'already been freed but not *really free*' memory? It's a
waste, and appears to be a lead up to a need for over-commitment.

How much time does it save? No really..

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