Re: max heap usage of a Linux process

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Prasanta Sadhukhan wrote:

> > > Actually, I have the process-pid(s) and I want to find out 
> > > programmatically, what's the max heap size that had been consumed by 
> > > that process at any given moment(based on user command) from another 
> > > process.
> > 
> > Then you need to read the files in /proc/<pid>/*. There isn't a system
> > call to get resource usage for another process.
> > 
> > Note that you won't be able to determine how much of the allocated
> > heap is free or used; that information is internal to the process, and
> > isn't visible externally.
> 
> thanks. Infact, I used /proc/<pid>/statm to find out total size, RSS and 
> shared memory from 1st 3 entries. Don't know about the accuracy or not 
> but that will do. But, this file does not tell about max. heap consumed 
> by a process nor does /proc/pid/status and I am not able to decipher 
> /proc/pid/stat. Does anyone knows how to interpret stat file?

It's documented in the proc(5) manpage, but I don't think it records
the heap size separately.

Probably the best option is to look in /proc/<pid>/maps for writable
segments with zero for the device and inode numbers (i.e. anonymous
maps).

Also, note that glibc's malloc can use explicit anonymous mmap() to
obtain memory, as well as sbrk(), so there isn't a monolithic "heap"
in the traditional sense.

-- 
Glynn Clements <glynn@xxxxxxxxxxxxxxxxxx>
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Assembler]     [Git]     [Kernel List]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [C Programming]     [Yosemite Campsites]     [Yosemite News]     [GCC Help]

  Powered by Linux