[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: free memory

On Sunday 16 November 2008 08:30:51 am Steve West wrote:
> I am running Fedora 9 x86 64 bit. I have 8 gigs of memory in the system.I
> wrote a program to malloc 4 gigs of memory space. Free shows nearly the
> same result before and during the execution of the program. Why does free
> not show that 4 gigs where allocated and used? How do I show the true
> memory usage?
> Steve

What you encounter is a documented, intended behavior. Different people refer 
to it by different names like delayed allocation or memory overcommit, but it 
addresses all the same issue. Essentially, there are so many programs out 
there that ask for memory and never use it, the kernel will overcommit 
memory. That means that malloc (with few exceptions) will succeed even if you 
don't really have that memory available. It isn't actually allocated until 
your process uses it. 

Change your program to touch every page of the memory you allocated (simple 
for loop accessing one word in each page is sufficient) and you'll see the 
memory usage of your program increase steadily. 

Search google for memory overcommit or delayed allocation. 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]