How to monitor a process memory utilization?

hi frnds,

I want to monitor a particular process very closly on how much memory it is taking. i tried with TOP and PRSTAT commands that is not giving what exactly i need. In my application, there is a memory leak happening, i want to know when it is occuering, means which transcation is causing that leak?

thanks in advance...

i wonder why does not top is not giving you the expected ? -- it should !

Anyway try pmap, check the #10 in this article for more clarification: 20 Linux System Monitoring Tools Every SysAdmin Should Know

maybe try using trace. from my understanding trace is supposed to log application execution. here is some info about it. trace - Linux Command - Unix Command

What about ps?

From your mention of prstat I assume you are on Solaris. If that is the case, dtrace is the tool to use.

Assuming none of the above are suitable, you can add this command to run every minute in your crontab:

ps  -o pid,addr,vsz,osz,rss,pmem,ltime,args -p pid >>/var/log/ps.log

If you don't know ahead of time the pid of the process, you can use:

pid=`ps -eo pid,comm | awk '$2 == name { print $1 }' name=command-name`

and use $pid in the cronjob command.

TOP should be giving the results you expecting.For such memory leak cases I use TOP Only.Jus try TOP -n 50 or 100 | grep <pid>.

If your are debugging a C++ application,put your application under dbx and this method should definitely work.

As you are running Solaris, install Sun Studio. The bundled dbx can help you figuring out if there is actually a leak and where it happens.

$ dbx /usr/bin/sleep
For information about new features see `help changes'
To remove this message, put `dbxenv suppress_startup_message 7.7' in your .dbxrc
Reading sleep
Reading ld.so.1
Reading libc.so.1
(dbx) check -leaks                                                           
leaks checking - ON
(dbx) run 10      
Running: sleep 10 
(process id 3032)
Reading rtcapihook.so
Reading libdl.so.1
Reading rtcaudit.so
Reading libmapmalloc.so.1
Reading libgen.so.1
Reading libm.so.2
Reading rtcboot.so
Reading librtc.so
RTC: Enabling Error Checking...
RTC: Running program...
Reading libshell.so.1
Reading libcmd.so.1
Reading libast.so.1
Reading fr_FR.UTF-8.so.3
Reading methods_unicode.so.3
Checking for memory leaks...

Actual leaks report    (actual leaks:            0  total size:          0 bytes)

Possible leaks report  (possible leaks:          0  total size:          0 bytes)

execution completed, exit code is 0

Libumem and mdb can also be helpful.

The command you are searching for is probably 'sar' this is usually not pre installed.. In opensuse it comes with the package sysstat.. google fot it to find and use..

Sar is always installed with Solaris but it cannot help pinpointing what specific process is using too much memory nor identifying a memory leak source.