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).
ulimit
look at ulimit, enter ulimit -a to see current settings
Heap Mem
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 -
Regards,
Jelari.
ps
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
I think brk() system call gives you current heapsize.
sbrk()
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\]'
grep '\[heap\]' /proc/1234567/maps
Could n't figure out
#include
#include
main ()
{
char *a;
a = malloc (100);
while (1);
}
#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.
-Happy Coding -
Regards,
Jelari.
Glibc will reserve heap for
Glibc will reserve heap for itself. A malloc does not necessarily influence the size of the heap as seen from the kernel.