For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > December 2004 > Dynamic memory in Unix









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Dynamic memory in Unix
my_gaurav@yahoo.com

2004-12-16, 8:58 am

Hi

Just wanted to know some details about the dynamic memory allocation in
Unix. When I start process a.out how exactly heap is allocated by the
kernel and is there any limit on the size of the heap.

Another thing is that when I do a free() or delete() the released
memory is not returned back to kernel ??

Regards,
Gaurav

Barry Margolin

2004-12-16, 4:05 pm

In article <1103188103.928484.50910@c13g2000cwb.googlegroups.com>,
my_gaurav@yahoo.com wrote:

> Hi
>
> Just wanted to know some details about the dynamic memory allocation in
> Unix. When I start process a.out how exactly heap is allocated by the
> kernel and is there any limit on the size of the heap.


Look up "break" in any book or web page on Unix internals.

>
> Another thing is that when I do a free() or delete() the released
> memory is not returned back to kernel ??


Usually true. Since the heap segment can only be grown or shrunk at one
end, the memory could only be returned if it happened to be at the end
of the segment. I think the GNU libc free() checks for this, but most
don't.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
David Schwartz

2004-12-16, 4:05 pm


<my_gaurav@yahoo.com> wrote in message
news:1103188103.928484.50910@c13g2000cwb.googlegroups.com...

> Another thing is that when I do a free() or delete() the released
> memory is not returned back to kernel ??


Physical memory or virtual memory? Physical memory is always released to
the kernel unless you specifically lock it. Virtual memory is not a scarce
resource, so why would you care whether it's released or not?

DS


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com