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