Re: [Ilugc] How to know the memory size of processes

2009-03-20 Thread sandeep mane
try ps -ax command.

On Fri, Mar 20, 2009 at 4:01 PM, Shrinivasan T tshriniva...@gmail.comwrote:

 Friends.

 I want to know how much memory does a process takes.

 How to know this?

 Top is showing only for TOP processes.

 Thanks.

 --
 Regards,
 T.Shrinivasan


 My experiences with Linux are here
 http://goinggnu.wordpress.com

 For Free and Open Source Jobs
 http://fossjobs.wordpress.com
 ___
 To unsubscribe, email ilugc-requ...@ae.iitm.ac.in with
 unsubscribe password address
 in the subject or body of the message.
 http://www.ae.iitm.ac.in/mailman/listinfo/ilugc

___
To unsubscribe, email ilugc-requ...@ae.iitm.ac.in with 
unsubscribe password address
in the subject or body of the message.  
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc


Re: [Ilugc] How to know the memory size of processes

2009-03-20 Thread Kenneth Gonsalves
On Friday 20 March 2009 16:01:11 Shrinivasan T wrote:
 Top is showing only for TOP processes.

man ps
-- 
regards
kg
http://lawgon.livejournal.com
___
To unsubscribe, email ilugc-requ...@ae.iitm.ac.in with 
unsubscribe password address
in the subject or body of the message.  
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc


Re: [Ilugc] How to know the memory size of processes

2009-03-20 Thread Kenneth Gonsalves
On Friday 20 March 2009 16:04:42 sandeep mane wrote:
 try ps -ax command.
'-' is deprecated and top posts ARE NOT WELCOME ON THIS LIST
-- 
regards
kg
http://lawgon.livejournal.com
___
To unsubscribe, email ilugc-requ...@ae.iitm.ac.in with 
unsubscribe password address
in the subject or body of the message.  
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc


Re: [Ilugc] How to know the memory size of processes

2009-03-20 Thread aditya

 Top is showing only for TOP processes.


You can do a top -p pid once you get the pid of the process (from
ps). Also, if you're running a recent version of top, hitting 'H' will
toggle between displaying individual thread statistics and a
consolidated view (if it's a multi-threaded process)
___
To unsubscribe, email ilugc-requ...@ae.iitm.ac.in with 
unsubscribe password address
in the subject or body of the message.  
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc


Re: [Ilugc] How to know the memory size of processes

2009-03-20 Thread Vikram Vincent
 Top is showing only for TOP processes.

Try 'htop'
-- 
Vikram Vincent
+919448810822
http://swatantra.org/
___
To unsubscribe, email ilugc-requ...@ae.iitm.ac.in with 
unsubscribe password address
in the subject or body of the message.  
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc


Re: [Ilugc] How to know the memory size of processes

2009-03-20 Thread Satish Eerpini
I don remember where I got this really neat python script from , but
I generally use it to check out the memory usage, and have found it to
be quite accurate :
__
import sys, os, string

if os.getuid() !=0:
sys.stderr.write(Running as non-root user\n);
#sys.exit(1)

#if os.getuid() !=500:
#sys.stderr.write(Other than root only Satish can run this script\n);
#sys.exit(1)
PAGESIZE=os.sysconf(SC_PAGE_SIZE)/1024 #KiB
our_pid=os.getpid()

#(major,minor,release)
def kernel_ver():
kv=open(/proc/sys/kernel/osrelease).readline().split(.)[:3]
for char in -_:
kv[2]=kv[2].split(char)[0]
return (int(kv[0]), int(kv[1]), int(kv[2]))

kv=kernel_ver()

have_pss=0

#return Private,Shared
#Note shared is always a subset of rss (trs is not always)
def getMemStats(pid):
global have_pss
Private_lines=[]
Shared_lines=[]
Pss_lines=[]
Rss=int(open(/proc/+str(pid)+/statm).readline().split()[1])*PAGESIZE
if os.path.exists(/proc/+str(pid)+/smaps): #stat
for line in open(/proc/+str(pid)+/smaps).readlines(): #open
if line.startswith(Shared):
Shared_lines.append(line)
elif line.startswith(Private):
Private_lines.append(line)
elif line.startswith(Pss):
have_pss=1
Pss_lines.append(line)
Shared=sum([int(line.split()[1]) for line in Shared_lines])
Private=sum([int(line.split()[1]) for line in Private_lines])
#Note Shared + Private = Rss above
#The Rss in smaps includes video card mem etc.
if have_pss:
pss_adjust=0.5 #add 0.5KiB as this average error due to trunctation
Pss=sum([float(line.split()[1])+pss_adjust for line in Pss_lines])
Shared = Pss - Private
elif (2,6,1) = kv = (2,6,9):
Shared=0 #lots of overestimation, but what can we do?
Private = Rss
else:
Shared=int(open(/proc/+str(pid)+/statm).readline().split()[2])
Shared*=PAGESIZE
Private = Rss - Shared
return (Private, Shared)

def getCmdName(pid):
cmd = file(/proc/%d/status % pid).readline()[6:-1]
exe = os.path.basename(os.path.realpath(/proc/%d/exe % pid))
if exe.startswith(cmd):
cmd=exe #show non truncated version
#Note because we show the non truncated name
#one can have separated programs as follows:
#584.0 KiB +   1.0 MiB =   1.6 MiBmozilla-thunder (exe - bash)
# 56.0 MiB +  22.2 MiB =  78.2 MiBmozilla-thunderbird-bin
return cmd

cmds={}
shareds={}
count={}
for pid in os.listdir(/proc/):
try:
pid = int(pid) #note Thread IDs not listed in /proc/ which is good
if pid == our_pid: continue
except:
continue
try:
cmd = getCmdName(pid)
except:
#permission denied or
#kernel threads don't have exe links or
#process gone
continue
try:
private, shared = getMemStats(pid)
except:
continue #process gone
if shareds.get(cmd):
if have_pss: #add shared portion of PSS together
shareds[cmd]+=shared
elif shareds[cmd]  shared: #just take largest shared val
shareds[cmd]=shared
else:
shareds[cmd]=shared
cmds[cmd]=cmds.setdefault(cmd,0)+private
if count.has_key(cmd):
   count[cmd] += 1
else:
   count[cmd] = 1

#Add shared mem for each program
total=0
for cmd in cmds.keys():
cmds[cmd]=cmds[cmd]+shareds[cmd]
total+=cmds[cmd] #valid if PSS available

sort_list = cmds.items()
sort_list.sort(lambda x,y:cmp(x[1],y[1]))
sort_list=filter(lambda x:x[1],sort_list) #get rid of zero sized processes

#The following matches du -h output
#see also human.py
def human(num, power=Ki):
powers=[Ki,Mi,Gi,Ti]
while num = 1000: #4 digits
num /= 1024.0
power=powers[powers.index(power)+1]
return %.1f %s % (num,power)

def cmd_with_count(cmd, count):
if count1:
   return %s (%u) % (cmd, count)
else:
   return cmd

print  Private  +   Shared  =  RAM used\tProgram \n
for cmd in sort_list:
print %8sB + %8sB = %8sB\t%s % (human(cmd[1]-shareds[cmd[0]]),
  human(shareds[cmd[0]]), human(cmd[1]),
  cmd_with_count(cmd[0], count[cmd[0]]))
if have_pss:
print - * 33
print   * 24 + %8sB % human(total)
print = * 33
print \n Private  +   Shared  =  RAM used\tProgram \n

#Warn of possible inaccuracies
#2 = accurate  can total
#1 = accurate only considering each process in isolation
#0 = some shared mem not reported
#-1= all shared mem not reported
def shared_val_accuracy():
http://wiki.apache.org/spamassassin/TopSharedMemoryBug;
if kv[:2] == (2,4):
if open(/proc/meminfo).read().find(Inact_) == -1:
return 1
return 0
elif kv[:2] == (2,6):
if 

Re: [Ilugc] How to know the memory size of processes

2009-03-20 Thread Shrinivasan T
Thanks friends.

For wonderful tools and script.





-- 
Regards,
T.Shrinivasan


My experiences with Linux are here
http://goinggnu.wordpress.com

For Free and Open Source Jobs
http://fossjobs.wordpress.com
___
To unsubscribe, email ilugc-requ...@ae.iitm.ac.in with 
unsubscribe password address
in the subject or body of the message.  
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc


Re: [Ilugc] How to know the memory size of processes

2009-03-20 Thread ராஜேந்திரன்


From: Shrinivasan T tshriniva...@gmail.com
To: ILUG-C ilugc@ae.iitm.ac.in
Sent: Friday, 20 March, 2009 4:01:11 PM
Subject: [Ilugc] How to know the memory size of processes

Friends.

I want to know how much memory does a process takes.

How to know this?

Top is showing only for TOP processes.

Thanks.

-- 
Regards,
T.Shrinivasan
___


You can use the following command:

pmap pid

Regards,
R Rajendhran


  Bring your gang together. Do your thing. Find your favourite Yahoo! group 
at http://in.promos.yahoo.com/groups/

___
To unsubscribe, email ilugc-requ...@ae.iitm.ac.in with
unsubscribe password address
in the subject or body of the message.
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc


[Ilugc] How to know the memory size of processes

2009-03-20 Thread sanjeev saini

   9. How to know the memory size of processes (Shrinivasan T)

 Friends.

 I want to know how much memory does a process takes.

 How to know this?

Hi this might be of some help to you
http://www.cyberciti.biz/tips/howto-find-memory-used-by-program.html

Regards
Sanjeev
___
To unsubscribe, email ilugc-requ...@ae.iitm.ac.in with 
unsubscribe password address
in the subject or body of the message.  
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc