I would like to know how to find the heap memory of a process that is running in the background. Is there any command that allows such?
Asked
Active
Viewed 7.0k times
11
1 Answers
12
If you want to look at a particular process named e.g. wing_ide
, then
ps a | fgrep wing_ide | fgrep -v fgrep
gives you a number at the beginning of the line (in my case 29837) use this number as follows:
fgrep '[heap]' /proc/29837/maps
The output look like:
01d56000-07026000 rw-p 00000000 00:00 0 [heap]
If you do this on a regular basis you might want to use the following python program:
import sys
import psutil
for p in psutil.process_iter():
if p.name == sys.argv[1]:
print(pid)
for map in p.get_memory_maps(grouped=False):
if '[heap]' in map.path:
print(map.addr)
To which program you provide the name of the process you want to search as an argument:
python findheap.py wing_ide

OverShifted
- 105

Anthon
- 79,293
-
Anton, How you made wing_ide in process list. I use as well and it shows as python, confusing with my own programs. – Gerard Apr 26 '13 at 11:07
-
@Gerard patched the startup script. If you make that into a question I will provide you with details. – Anthon Apr 26 '13 at 11:16
-
-
-
@ChopLabalagun use
man proc
and search formaps
that section has a detailed explanation, Preferably though you shouldn't abuse comments for questions like this, but post your question as a Question on this site instead. – Anthon Jun 19 '20 at 04:07 -
/proc/$PID/maps
, wher$PID
is the pid of the process you want to examine. – Kotte Apr 25 '13 at 08:12