博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
关于进程的物理内存RSS
阅读量:2432 次
发布时间:2019-05-10

本文共 3111 字,大约阅读时间需要 10 分钟。

通常习惯直接把ps里的RSS看做是进程使用的物理内存。
例如linux下ps的说明如下
rss        RSS      resident set size, the non-swapped physical memory that a task has used
                    (in kiloBytes). (alias rssize, rsz).
随便在笔记本虚机上看一个oracle进程,居然有30M之巨
[oracle@server2 ~]$ ps aux | head -n 1; ps aux | grep LOCAL=YES| grep -v grep
USER       PID %CPU %MEM    VSZ   
RSS TTY      STAT START   TIME COMMAND
oracle    2295  0.0  1.6 856044 
30764 ?        Ss   21:23   0:00 oracleorcl (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
再比如这台惠普,有1823个远程连接。
SQL> !ps -ef| grep LOCAL=NO| wc -l
1823
glance里按RSS排序,直接看最后一页,最少都是200多兆,这么算起来400多G。
                         User      CPU %    Thrd Disk        Memory       Block
Process Name     PID     Name   (12800%max) Cnt  IOrate      RSS/VSS      On
--------------------------------------------------------------------------------
oraclePRODB2       17050 grid          0.0     1   0.0  
226.5mb  241.9mb SOCKT
oraclePRODB2        7029 grid          0.0     1   0.0  
216.6mb  218.9mb SOCKT
oraclePRODB2       16306 grid          0.0     1   0.0  
227.8mb  239.3mb SOCKT
oraclePRODB2       17114 grid          0.1     1   0.0  
224.3mb  243.7mb SOCKT
oraclePRODB2       15957 grid          0.0     1   0.0  
226.5mb  240.2mb SOCKT 
...
...
但是这台机器的
物理内存一个1T,
SGA就固定400G,现在用户进程只用了447G,因此按进程上的RSS简单相加肯定是不准的。
Event         Current   Cumulative   Current Rate   Cum Rate   High Rate
--------------------------------------------------------------------------------
Page Faults       858         4050       343.2      470.9       662.5
Page In             0            0         0.0        0.0       148.9
Page Out            0            0         0.0        0.0         0.0
KB Paged In       0kb          0kb         0.0        0.0         0.0
KB Paged Out      0kb          0kb         0.0        0.0         0.0
Reactivations       0            0         0.0        0.0         0.0
Deactivations       0            0         0.0        0.0         0.0
KB Deactivated    0kb          0kb         0.0        0.0         0.0
VM Reads            0            0         0.0        0.0         0.0
VM Writes           0            0         0.0        0.0         0.0
Total VM : 464.7gb   Sys Mem  : 104.9gb   
User Mem: 447.8gb   Phys Mem :  1023gb
Active VM: 261.3gb   Buf Cache:     0mb   Free Mem: 455.8gb   FileCache:  14.5gb
MemFS Blk Cnt:                0   MemFS Swp Cnt:                0

以进程17050为例,glance里显示226.5m。查看pga实际分配了3M
SQL> select round(pga_alloc_mem/1024/1024, 2)||' (MB)' alloc_mb from v$process where spid = 17050;
ALLOC_MB
-----------------
3.09
 (MB)
整个PGA一共也就分配了11G
SQL> select round(sum(pga_alloc_mem)/1024/1024/1024, 2)||' (GB)' sum_alloc_mb from v$process;
SUM_ALLOC_MB
---------------------------------------------
11.47
 (GB)
于是查看glance里RSS的说明
On HP-UX, for processes that use CPU
time subsequent to midaemon startup,
the resident memory is calculated as
                                   
RSS = sum of private region pages 
+
      
(sum of shared region pages /
       number of references)
       
                                   
The number of references is a count
of the number of attachments to the
memory region.
  Attachments, for   
shared regions, may come from      
several processes sharing the same 
memory, a single process with      
multiple attachments, or           
combinations of these.
This value is only updated when a
process uses CPU.Thus, under
memory pressure, this value may be 
higher than the actual amount of   
resident memory for processes which
are idle
 because their memory pages
may no longer be resident or the   
reference count for shared segments
may have changed.
上面提到有两个原因会造成RSS显示远大于进程实际使用的内存
  1. RSS除了进程私有物理内存之外,还要加上[它所使用的共享内存大小 / 所有正在使用这个共享内存的进程数]。
  2. 由于RSS只有在进程使用CPU时才更新,如果进程idle了,就再也不会更新,永远是那么大。
因此每个进程最少200多M,应该就是通过SGA的400000 / 1823 = 219 算出来的。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26239116/viewspace-1472417/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/26239116/viewspace-1472417/

你可能感兴趣的文章
Routing
查看>>
json相关学习
查看>>
linux下access函数的应用
查看>>
linux系统调用之文件:递归删除非空目录
查看>>
linux下获取系统时间的方法
查看>>
ubuntu12.04安装openCV2.4.6.1
查看>>
jsp与servlet的作用以及区别--为什么说JSP底层就是一个Servlet
查看>>
看HashMap源码前的必备冷知识,白话文式教学,适合刚开始了解源码的新手观看
查看>>
Oracle安装指南
查看>>
Redis面试必备(一)
查看>>
Cookie对象入门详解
查看>>
HashMap的remove()方法详解
查看>>
单例模式-分解步骤,逐步解析
查看>>
通过Form表单一次性拿到json格式数据,及后台接收
查看>>
## EL表达式与JSTL标签用法解读
查看>>
Mybatis异常:The content of elements must consist of well-formed.......(一般出现在写分页/带大于小于号的SQL)
查看>>
Mybatis光速入门(配置文件模块)
查看>>
关于Oracle的主键自增如何设置
查看>>
手撕HashMap的resize()方法源码渗透解析+图解
查看>>
Mybatis常见异常类型Could not set parameters for mapping离不开这个原因!
查看>>