How can i determine how much heap space is allocated for a particular process?
Is there any configuration file that i can look at?
look at ulimit, enter ulimit -a to see current settings
No, I just want to know how much of heap memory is allocated for a particular process?.. Is there any command through which i can figure out with pid.
-Happy Coding -
ps can do that. as a start try "ps l" and then examine the "format specifiers".
if you want to be non-portable, you can also consult /proc/<pid>/status and proc/<pid>/maps.
I think brk() system call gives you current heapsize.
brk() returns 0 on success or -1 on error. you can use the derived library function sbrk() to get the current program break (i.e. heap end pointer) (call sbrk(0)), but you then have to find out the start pointer... and it is perfectly possible to allocate heap memory without moving the program break (using mmap() with flags MAP_ANONYMOUS|MAP_PRIVATE).
grep '\[heap\]' /proc/1234567/maps
a = malloc (100);
#grep '\[heap\]' /proc/maps
I could not able to differentiate the heap size if the size of allocation is changed to 10 or 20. the maps shows the same memory difference.
Glibc will reserve heap for itself. A malloc does not necessarily influence the size of the heap as seen from the kernel.