Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I know VSZ in ps is for the total address space allocated for the app and is sometimes aliased as vsize (mentioned in man page of ps on linux), but what's the definition of VSIZE in top? This top output from iPhone is different from the top on Linux:

 PID COMMAND      %CPU   TIME   #TH #PRTS #MREGS  RPRVT  RSHRD  RSIZE  VSIZE
 1875 emma         0.0%  0:30.83   7   139    932 17868K  5328K    29M   181M

root# ps -eo pid,rss,vsz|grep 1875
 1875  29324   441324
share|improve this question
    
I can't reproduce this on any of my darwin machines. It makes me think the shell that they setup on the iphone had a weird blocksize set? –  polynomial Aug 27 '11 at 3:47
    
they look to be calculating RSIZE/rss the same way, but ps is reporting a vsz 2.5x larger than that reported by top. maybe top on IOS doesn't include shared objects in vsize, or something. –  Tim Kennedy Oct 2 '11 at 4:52
    
"This top output from iPhone is different from the top on Linux" — isn't a surprise, is it? –  poige May 23 '13 at 1:35

1 Answer 1

Linux memory system is filled with many routines of memory optimization utilities and memory sharing, making the very idea of how memory is shared and being consumed among, a cumbersome approach.The output of ps and other ps related commands all work up their output from data under /proc filesystem. Particularly ps, RSS(resident size memory) and VSIZE(Virtual memory size) are both important, however VSIZE does not show the accurate usage of the memory and the difference between VSIZE and rss is what is actually intended and allocated to the program during the initialization but may not be referenced yet. Like the program may have lots of libraries linked but they are not loaded yet because they are not referenced yet in the actual program runtime. RSS gives the total memory actually used by the program but may not give a true picture of the memory consumption, since most of the memory allocated may be shared with other instances of the same process or other processes. Looking under /proc/<processid>/maps may give a rough idea of how the memory has been used but they quiet can be misleading sometimes. Use pmap -x <pid> from commandline, useful to see the spreadup is.

The often better utilities are free and vmstat. free will give you overall current memory consumption details and vmstat can be used to see how often it is being updated.

share|improve this answer
    
Another reason or thoughtful explanation why ps should NOT be considered to be giving correct process memory usage. Read this at virtualthreads.blogspot.com/2006/02/… –  Nikhil Mulley Dec 2 '11 at 19:39
1  
What the poster of this answer is trying to say is that the definition of memory used is complex and varied. There is no single place in the kernel where it is tracked and reported. The utilities perform their own interpretation of the numerous statistics that are reported by the kernel. –  Johan Apr 11 '13 at 12:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.