Re: memory usage by a process
From: Basile Starynkevitch [news] (basile-news_at_starynkevitch.net)
Date: 04/29/05
- Previous message: niraj.kumar.ait_at_gmail.com: "memory usage by a process"
- In reply to: niraj.kumar.ait_at_gmail.com: "memory usage by a process"
- Next in thread: invincible: "Re: memory usage by a process"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 29 Apr 2005 06:00:24 +0000 (UTC)
On 2005-04-29, niraj.kumar.ait@gmail.com <niraj.kumar.ait@gmail.com> wrote:
> Is their any system call or library to find the memory usage of a
you didn't define precisely what you mean by memory usage. In
particular are you thinking of virtual memory space or physical RAM
usage (which is ill-defined, since a process also consumes the cache
for files it accesses).
I assume you are interested by virtual memory space
> particular process nd total cpu utilization of a particular system.
Ypu might consider using the getrusage(2) system call.
> I dont wanna use top command and proc directory.
I might understand that you don't want to use top or ps, but I don't
understand why you don't want to use /proc
From inside your program, a simple way to ask for its memory mapping
is to read and parse the /proc/self/maps file. For an example, run
the command "cat /proc/self/maps" which on my system (Debian/Sid) gives
the map of the process running cat
% cat /proc/self/maps
08048000-0804c000 r-xp 00000000 03:02 2828919 /bin/cat
0804c000-0804d000 rw-p 00003000 03:02 2828919 /bin/cat
0804d000-0806e000 rw-p 0804d000 00:00 0 [heap]
b7bca000-b7dca000 r--p 00000000 03:03 718366 /usr/lib/locale/locale-archive
b7dca000-b7dcb000 rw-p b7dca000 00:00 0
b7dcb000-b7ef5000 r-xp 00000000 03:02 3597455 /lib/tls/libc-2.3.2.so
b7ef5000-b7efe000 rw-p 00129000 03:02 3597455 /lib/tls/libc-2.3.2.so
b7efe000-b7f00000 rw-p b7efe000 00:00 0
b7f23000-b7f24000 rw-p b7f23000 00:00 0
b7f24000-b7f3a000 r-xp 00000000 03:02 1177349 /lib/ld-2.3.2.so
b7f3a000-b7f3b000 rw-p 00015000 03:02 1177349 /lib/ld-2.3.2.so
bf825000-bf83a000 rw-p bf825000 00:00 0 [stack]
ffffe000-fffff000 ---p 00000000 00:00 0 [vdso]
From another program (or a shell), to get the memory mapping of
process 1234 just read /proc/1234/maps
Regards
-- Basile STARYNKEVITCH http://starynkevitch.net/Basile/ email: basile<at>starynkevitch<dot>net aliases: basile<at>tunes<dot>org = bstarynk<at>nerim<dot>net 8, rue de la Faïencerie, 92340 Bourg La Reine, France
- Previous message: niraj.kumar.ait_at_gmail.com: "memory usage by a process"
- In reply to: niraj.kumar.ait_at_gmail.com: "memory usage by a process"
- Next in thread: invincible: "Re: memory usage by a process"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|