On Nov 5, 10:28 pm, himanshu kansal <himanshukansal...@gmail.com>
wrote:
> can we know the size of heap memory allocated to our program????

Hi,
     from my knowledge of OS, when program is loaded in the memory the
heap is not allocated to the process.
as the requests made by the process, the memory will be allocated from
the virtual memory area (VMA) of the process by the kernel. As the
Data and code sections are fixed in the address space of the process
the remaining address space is utilized for the heap and the stack.
the heap of the process is managed by the virtual memory manager.

And the frames for the process (Physical memory) will also be
allocated by the kernel at the run time for the same. Kernel it self
does the virtual to physical and physical to virtual translations
while allocating virtual memory.  Kernel maintains the pools of the
memory, where each pool represents blocks of memory of a certain power
of two in size. If a smaller size is requested than is available, the
smallest available size is selected and it is then broken in two. One
of the resulting halves is selected, and the process repeats (checking
the size again and splitting if needed) until the block is just large
enough. All new blocks that are formed during these splits are added
to their respective memory pools for later use.
>
> i think sbrk(0) will return the address of end of heap.....
> but how to find the start of heap so that we can calculate the size of
> total heap memory allocated to our program....
>
> is there any way possible????

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to