1

I want to write an function in c code to find the free heap space available, so i decided to find the diff. b/w program break and stack pointer that will give the heap space available. I used sbrk(0) to find the program break value i observed "Program break value was increasing continuously" every time I run my executable.

1) Why is it increasing every time? if the heap and stack at address space are individual for each process it should not increase until I call malloc() right?

2) please let me know if i'am using right logic to find the heap space available, if not please explain correct logic to do it.

Os:Linux Code:C

  • http://unix.stackexchange.com/questions/73627/how-to-find-heap-memory-of-a-running-process – nikhil mehta Mar 21 '14 at 11:30
  • "But later i found that the memory b/w those two pointers might be mapped for other processes as well" No. The address space is always used by one process exclusively. (The actual, physical memory used is completely out of your control; it can be anywhere.) – glglgl Mar 21 '14 at 14:00

0 Answers0