Reputation: 11044
Is there any way to find the starting and ending address of heap memory.
#include<stdio.h>
void main()
{
printf("Ending address of Heap: %x\n",sbrk(0));
}
The above coding shows the ending address of heap memory. Like that is there any way to find the starting address of heap.
Output:
Ending address of Heap: 8556000
Upvotes: 8
Views: 3271
Reputation: 9394
On Linux you can open file /proc/self/maps, for example with fopen, and read it until you find line like this:
0060f000-00630000 rw-p 00000000 00:00 0 [heap]
0060f000-00630000 - address range of heap
Upvotes: 2