精华内容
下载资源
问答
  • 转载一个shell统计linux系统中每个程序的内存使用情况,因为内存结构非常复杂,不一定100%精确,此shell可以在Ghub上下载。 [root@db231 ~]# ./memstat.sh Private + Shared = RAM used Program 540.78 mb + ...

    转载一个shell统计linux系统中每个程序的内存使用情况,因为内存结构非常复杂,不一定100%精确,此shell可以在Ghub上下载。

    [root@db231 ~]# ./memstat.sh  
    Private          +       Shared          =       RAM used        Program
    540.78 mb        +       175.56 mb       =       716.35 mb       oracle(25)
    24.50 mb         +       327.00 kb       =       24.82 mb        iscsiuio
    15.37 mb         +       341.00 kb       =       15.70 mb        yum-updatesd
    12.51 mb         +       853.00 kb       =       13.35 mb        gdmgreeter
    11.69 mb         +       74.00 kb        =       11.77 mb        tnslsnr
    4.74 mb          +       302.00 kb       =       5.03 mb         Xorg
    1.42 mb          +       1016.00 kb      =       2.41 mb         smbd(2)
    2.04 mb          +       347.00 kb       =       2.38 mb         gdm-rh-security
    1.83 mb          +       433.00 kb       =       2.25 mb         sshd(2)
    1.51 mb          +       379.00 kb       =       1.88 mb         iscsid(2)
    748.00 kb        +       958.00 kb       =       1.66 mb         gdm-binary(2)
    1.02 mb          +       134.00 kb       =       1.15 mb         cupsd
    ...
    --------------------------------------------------------
                                                     808.08 mb 
    ========================================================
    [root@db231 ~]# free
                 total       used       free     shared    buffers     cached
    Mem:       8174740    7339076     835664          0     486208    6085484
    -/+ buffers/cache:     767384    7407356
    Swap:      8393920      19996    8373924
    
    

    memory stat shell

    #!/bin/bash
    # Make sure only root can run our script
    
    if [ "$(id -u)" != "0" ]; then
    echo "This script must be run as root" 1>&2
    exit 1
    fi
    
    ### Functions
    #This function will count memory statistic for passed PID
    get_process_mem ()
    {
    PID=$1
    #we need to check if 2 files exist
    if [ -f /proc/$PID/status ];
    then
    if [ -f /proc/$PID/smaps ];
    then
    #here we count memory usage, Pss, Private and Shared = Pss-Private
    Pss=`cat /proc/$PID/smaps | grep -e "^Pss:" | awk '{print $2}'| paste -sd+ | bc `
    Private=`cat /proc/$PID/smaps | grep -e "^Private" | awk '{print $2}'| paste -sd+ | bc `
    #we need to be sure that we count Pss and Private memory, to avoid errors
    if [ x"$Rss" != "x" -o x"$Private" != "x" ];
    then
    
    let Shared=${Pss}-${Private}
    Name=`cat /proc/$PID/status | grep -e "^Name:" |cut -d':' -f2`
    #we keep all results in bytes
    let Shared=${Shared}*1024
    let Private=${Private}*1024
    let Sum=${Shared}+${Private}
    
    echo -e "$Private + $Shared = $Sum \t $Name"
    fi
    fi
    fi
    }
    
    #this function make conversion from bytes to Kb or Mb or Gb
    convert()
    {
    value=$1
    power=0
    #if value 0, we make it like 0.00
    if [ "$value" = "0" ];
    then
    value="0.00"
    fi
    
    #We make conversion till value bigger than 1024, and if yes we divide by 1024
    while [ $(echo "${value} > 1024"|bc) -eq 1 ]
    do
    value=$(echo "scale=2;${value}/1024"|bc)
    let power=$power+1
    done
    
    #this part get b,kb,mb or gb according to number of divisions
    case $power in
    0) reg=b;;
    1) reg=kb;;
    2) reg=mb;;
    3) reg=gb;;
    esac
    
    echo -n "${value} ${reg} "
    }
    
    #to ensure that temp files not exist
    [[ -f /tmp/res ]] && rm -f /tmp/res
    [[ -f /tmp/res2 ]] && rm -f /tmp/res2
    [[ -f /tmp/res3 ]] && rm -f /tmp/res3
    
    #if argument passed script will show statistic only for that pid, of not  we list all processes in /proc/ #and get statistic for all of them, all result we store in file /tmp/res
    if [ $# -eq 0 ]
    then
    pids=`ls /proc | grep -e [0-9] | grep -v [A-Za-z] `
    for i in $pids
    do
    get_process_mem $i >> /tmp/res
    done
    else
    get_process_mem $1>> /tmp/res
    fi
    
    #This will sort result by memory usage
    cat /tmp/res | sort -gr -k 5 > /tmp/res2
    
    #this part will get uniq names from process list, and we will add all lines with same process list
    #we will count nomber of processes with same name, so if more that 1 process where will be
    # process(2) in output
    for Name in `cat /tmp/res2 | awk '{print $6}' | sort | uniq`
    do
    count=`cat /tmp/res2 | awk -v src=$Name '{if ($6==src) {print $6}}'|wc -l| awk '{print $1}'`
    if [ $count = "1" ];
    then
    count=""
    else
    count="(${count})"
    fi
    
    VmSizeKB=`cat /tmp/res2 | awk -v src=$Name '{if ($6==src) {print $1}}' | paste -sd+ | bc`
    VmRssKB=`cat /tmp/res2 | awk -v src=$Name '{if ($6==src) {print $3}}' | paste -sd+ | bc`
    total=`cat /tmp/res2 | awk '{print $5}' | paste -sd+ | bc`
    Sum=`echo "${VmRssKB}+${VmSizeKB}"|bc`
    #all result stored in /tmp/res3 file
    echo -e "$VmSizeKB + $VmRssKB = $Sum \t ${Name}${count}" >>/tmp/res3
    done
    
    #this make sort once more.
    cat /tmp/res3 | sort -gr -k 5 | uniq > /tmp/res
    
    #now we print result , first header
    echo -e "Private \t + \t Shared \t = \t RAM used \t Program"
    #after we read line by line of temp file
    while read line
    do
    echo $line | while read a b c d e f
    do
    #we print all processes if Ram used if not 0
    if [ $e != "0" ]; then
    #here we use function that make conversion
    echo -en "`convert $a` \t $b \t `convert $c` \t $d \t `convert $e` \t $f"
    echo ""
    fi
    done
    done < /tmp/res
    
    #this part print footer, with counted Ram usage
    echo "--------------------------------------------------------"
    echo -e "\t\t\t\t\t\t `convert $total`"
    echo "========================================================"
    
    # we clean temporary file
    [[ -f /tmp/res ]] && rm -f /tmp/res
    [[ -f /tmp/res2 ]] && rm -f /tmp/res2
    [[ -f /tmp/res3 ]] && rm -f /tmp/res3
    
    

    --注意全角引号

    [oracle@dbserver89 ~]$ pmap  -d 5502
    5502:   oracleora11g (LOCAL=NO)
    Address           Kbytes Mode  Offset           Device    Mapping
    0000000000400000  183540 r-x-- 0000000000000000 008:00006 oracle
    000000000b93c000    1884 rwx-- 000000000b33c000 008:00006 oracle
    000000000bb13000     304 rwx-- 000000000bb13000 000:00000   [ anon ]
    000000001819f000     544 rwx-- 000000001819f000 000:00000   [ anon ]
    0000000060000000   32768 rwxs- 0000000000000000 000:0000c 13 (deleted)
    ffffffffff600000    8192 ----- 0000000000000000 000:00000   [ anon ]
    ...
    mapped: 4753296K    writeable/private: 8536K    shared: 4507648K

    转载于:https://www.cnblogs.com/travel6868/p/5016164.html

    展开全文
  • matlab开发-memoryLinux

    2019-11-15 04:04:05
    matlab开发-memoryLinuxLinux的简要内存统计
  • Linux-Memory小记

    2016-12-31 11:04:00
    以前我对这块认识很模糊,而且还有错误的认识;今天由我同事提醒,所以我决定来好好...参数含义-----------------------------------------------------------------------Mem:表示物理内存统计 total: 表示系统总...

    以前我对这块认识很模糊,而且还有错误的认识;今天由我同事提醒,所以我决定来好好的缕缕这块的关系。

    图:



      

    -------------------------------------------1.参数含义-----------------------------------------------------------------------
    Mem:表示物理内存统计
       total: 表示系统总物理内存5993156kb(约5852M)
       used: 表示总计分配给缓存(包含buffers 与cached),但其中可能部分缓存未实际使用
       free:表示未分配的内存
       shared: 表示共享内存
       buffers:表示系统分配但未被使用的buffers数量
       cached:表示系统分配但未被使用的cache的数量

    在Free命令中显示的buffer和cache,它们都是占用内存:
    buffer :   作为buffer cache的内存,是块设备的读写缓冲区,更靠近存储设备,或者直接就是disk的缓冲区。
    cached:  作为page cache的内存, 文件系统的cache,是memory的缓冲区 。
    如果cached 的值很大,说明cache住的文件数很多。如果频繁访问到的文件都能被cache住,那么磁盘的读IO 必会非常小 。


    -/+ buffers/cached:   表示物理内存的缓存统计
       used: 表示实际使用的buffers与cache的总量,这就是实际使用的内存总量
       free:  表示未被使用的buffers与cache和未被分配的内存之和,这就是系统当前实际可能内存(所以一般linux机器看可用内存就看此值)

    Swap:   表示硬盘上交换分区的使用情况。只有mem被当前进程实际占用完,即没有了buffers和cache时,才会使用到swap。

    -------------------------------------------2.常用概念-----------------------------------------------------------------------
    物理内存总大小 :
    mem.total=mem.used+mem.free
    mem.total=(-/+ buffers/cached).used+(-/+ buffers/cached).free

    已经分配的内存大小:
    mem.used=mem.buffers+mem.cached+(-/+ buffers/cached).used

    实际可用内存大小:
    (-/+ buffers/cached).free=mem.free+mem.buffers+mem.cached


    -------------------------------------------3.手工清除缓存------------------------------------------------------------------
    # sync
    # echo 1 > /proc/sys/vm/drop_caches
      echo 2 > /proc/sys/vm/drop_caches
      echo 3 > /proc/sys/vm/drop_caches

    cache释放:
    a.To free pagecache:
    echo 1 > /proc/sys/vm/drop_caches

    b.To free dentries and inodes:
    echo 2 > /proc/sys/vm/drop_caches

    c.To free pagecache, dentries and inodes:
    echo 3 > /proc/sys/vm/drop_caches

    说明,释放前最好sync一下,防止丢数据。

    -------------------------------------------4.常见疑惑-----------------------------------------------------------------------
    1.用户常见的疑问是,为什么free这么小,是否关闭应用后内存没有释放?
       但实际上,我们都知道这是因为Linux对内存的管理与Windows不同,free小并不是说内存不够用了,应该看的是free的第二行最后一个值:-/+ buffers/cache: 2592892Kb,这才是系统可用的内存大小。

    2.free内存还有200M,cache里有58G,然后程序就跪了,抛了个tcmalloc allocation failed 65536, out of memory(needed 65312 bytes). 需要内存时为什么cache里面的没能释放?
       cache 中有程序在占用就无法释放了。

    3.有时候free太小,cached特别大时启动mysql会报错,这个是什么原因?
        这说明内存确实不够,cached并不是全部可以释放的,有程序占用就不能释放了

    4.我的Linux上cache占满RAM时系统非常慢,系统也不自动释放cache。所以号称“cache对性能只有好处而没坏处”是假的!
       这个要看你实际是使用的应用是什么。cache能带来的好处是,减轻频繁读写硬盘的需要,也就是降低IO,这特别是对于服务器上的应用来说是很常见的。相反,如果cache需要频繁更新,那会出现您提到的问题了

    展开全文
  • [Linux系列] Memory Performance Statistics

    千次阅读 2012-11-22 00:13:19
    内存性能统计,英文原版,原滋原味! ,原版的资料对于技术的细节描述,有时会更精确。 -------------------------- 3.1. Memory Performance Statistics Each system-wide Linux performance tool provides ...

    --------------------------

    内存性能统计,英文原版,原滋原味! ,原版的资料对于技术的细节描述,有时会更精确。

    --------------------------

    3.1. Memory Performance Statistics

    Each system-wide Linux performance tool provides different ways to extract similar statistics. Although no tool displays all the statistics, some of the tools display the same statistics. The beginning of this chapter reviews the details of these statistics, and those descriptions are then referenced as the tools are described.

    3.1.1. Memory Subsystem and Performance

    In modern processors, saving information to and retrieving information from the memory subsystem usually takes longer than the CPU executing code and manipulating that information. The CPU usually spends a significant amount of time idle, waiting for instructions and data to be retrieved from memory before it can execute them or operate based on them. Processors have various levels of cache that compensate for the slow memory performance. Tools such asoprofilecan show where various processor cache misses can occur.

    3.1.2. Memory Subsystem (Virtual Memory)

    Any given Linux system has a certain amount of RAM or physical memory. When addressing this physical memory, Linux breaks it up into chunks or "pages" of memory. When allocating or moving around memory, Linux operates on page-sized pieces rather than individual bytes. When reporting some memory statistics, the Linux kernel reports the number of pages per second, and this value can vary depending on the architecture it is running on.Listing 3.1 creates a small application that displays the number of bytes per page for the current architecture.

    Listing 3.1.
    #include <unistd.h>
    
    int main(int argc, char *argv[])
    
    {
    
      printf("System page size: %d\n",getpagesize());
    
    }

    On the IA32 architecture, the page size is 4KB. In rare cases, these page-sized chunks of memory can cause too much overhead to track, so the kernel manipulates memory in much bigger chunks, known as HugePages. These are on the order of 2048KB rather than 4KB and greatly reduce the overhead for managing very large amounts of memory. Certain applications, such as Oracle, use these huge pages to load an enormous amount of data in memory while minimizing the overhead that the Linux kernel needs to manage it. If HugePages are not completely filled with data, these can waste a significant amount of memory. A half-filled normal page wastes 2KB of memory, whereas a half-filled HugePage can waste 1,024KB of memory.

    The Linux kernel can take a scattered collection of these physical pages and present to applications a well laid-out virtual memory space.

    3.1.2.1 Swap (Not Enough Physical Memory)

    All systems have a fixed amount of physical memory in the form. of RAM chips. The Linux kernel allows applications to run even if they require more memory than available with the physical memory. The Linux kernel uses the hard drive as a temporary memory. This hard drive space is called swap space.

    Although swap is an excellent way to allow processes to run, it is terribly slow. It can be up to 1,000 times slower for an application to use swap rather than physical memory. If a system is performing poorly, it usually proves helpful to determine how much swap the system is using.

    3.1.2.2 Buffers and Cache (Too Much Physical Memory)

    Alternatively, if your system has much more physical memory than required by your applications, Linux will cache recently used files in physical memory so that subsequent accesses to that file do not require an access to the hard drive. This can greatly speed up applications that access the hard drive frequently, which, obviously, can prove especially useful for frequently launched applications. The first time the application is launched, it needs to be read from the disk; if the application remains in the cache, however, it needs to be read from the much quicker physical memory. This disk cache differs from the processor cache mentioned in the previous chapter. Other thanoprofile,valgrind, andkcachegrind, most tools that report statistics about "cache" are actually referring to disk cache.

    In addition to cache, Linux also uses extra memory as buffers. To further optimize applications, Linux sets aside memory to use for data that needs to be written to disk. These set-asides are called buffers. If an application has to write something to the disk, which would usually take a long time, Linux lets the application continue immediately but saves the file data into a memory buffer. At some point in the future, the buffer is flushed to disk, but the application can continue immediately.

    It can be discouraging to see very little free memory in a system because of the cache and buffer usage, but this is not necessarily a bad thing. By default, Linux tries to use as much of your memory as possible. This is good. If Linux detects any free memory, it caches applications and data in the free memory to speed up future accesses. Because it is usually a few orders of magnitude faster to access things from memory rather than disk, this can dramatically improve overall performance. When the system needs the cache memory for more important things, the cache memory is erased and given to the system. Subsequent access to the object that was previously cached has to go out to disk to be filled.

    3.1.2.3 Active Versus Inactive Memory

    Active memory is currently being used by a process. Inactive memory is memory that is allocated but has not been used for a while. Nothing is essentially different between the two types of memory. When required, the Linux kernel takes a process's least recently used memory pages and moves them from the active to the inactive list. When choosing which memory will be swapped to disk, the kernel chooses from the inactive memory list.

    3.1.2.4 High Versus Low Memory

    For 32-bit processors (for example, IA32) with 1GB or more of physical of memory, Linux must manage the physical memory as high and low memory. The high memory is not directly accessible by the Linux kernel and must be mapped into the low-memory range before it can be used. This is not a problem with 64-bit processors (such as AMD64/ EM6T, Alpha, or Itanium) because they can directly address additional memory that is available in current systems.

    3.1.2.5 Kernel Usage of Memory (Slabs)

    In addition to the memory that applications allocate, the Linux kernel consumes a certain amount for bookkeeping purposes. This bookkeeping includes, for example, keeping track of data arriving from network and disk I/O devices, as well as keeping track of which processes are running and which are sleeping. To manage this bookkeeping, the kernel has a series of caches that contains one or more slabs of memory. Each slab consists of a set of one or more objects. The amount of slab memory consumed by the kernel depends on which parts of the Linux kernel are being used, and can change as the type of load on the machine changes.


    展开全文
  • Linux性能统计 - vmstat

    2014-06-21 18:54:09
     很显然从名字中我们就可以知道vmstat是一个查看虚拟内存(Virtual Memory)使用状况的工具,但是怎样通过vmstat来发现系统中的瓶颈呢?在回答这个问题前,还是让我们回顾一下Linux中关于虚拟内存相关内容。   ...

    1.前言 

      很显然从名字中我们就可以知道vmstat是一个查看虚拟内存(Virtual Memory)使用状况的工具,但是怎样通过vmstat来发现系统中的瓶颈呢?在回答这个问题前,还是让我们回顾一下Linux中关于虚拟内存相关内容。

    2.虚拟内存原理 

      在系统中运行的每个进程都需要使用到内存,但不是每个进程都需要每时每刻使用系统分配的内存空间。当系统运行所需内存超过实际的物理内存,内核会释放某些进程所占用但未使用的部分或所有物理内存,将这部分资料存储在磁盘上直到进程下一次调用,并将释放出的内存提供给有需要的进程使用。 

      在Linux内存管理中,主要是通过“调页Paging”和“交换Swapping”来完成上述的内存调度。调页算法是将内存中最近不常使用的页面换到磁盘上,把活动页面保留在内存中供进程使用。交换技术是将整个进程,而不是部分页面,全部交换到磁盘上。 

      分页(Page)写入磁盘的过程被称作Page-Out,分页(Page)从磁盘重新回到内存的过程被称作Page-In。当内核需要一个分页时,但发现此分页不在物理内存中(因为已经被Page-Out了),此时就发生了分页错误(Page Fault)。 

      当系统内核发现可运行内存变少时,就会通过Page-Out来释放一部分物理内存。经管Page-Out不是经常发生,但是如果Page-out频繁不断的发生,直到当内核管理分页的时间超过运行程式的时间时,系统效能会急剧下降。这时的系统已经运行非常慢或进入暂停状态,这种状态亦被称作thrashing(颠簸)。

     

    3.vmstat详解 

    1.用法 

    vmstat [-a] [-n] [-S unit] [delay [ count]]

    vmstat [-s] [-n] [-S unit]

    vmstat [-m] [-n] [delay [ count]]

    vmstat [-d] [-n] [delay [ count]]

    vmstat [-p disk partition] [-n] [delay [count]]

    vmstat [-f]

    vmstat [-V]

     

    -a:显示活跃和非活跃内存 

    -f:显示从系统启动至今的fork数量 。 

    -m:显示slabinfo 

    -n:只在开始时显示一次各字段名称。 

    -s:显示内存相关统计信息及多种系统活动数量。 

    delay:刷新时间间隔。如果不指定,只显示一条结果。 

    count:刷新次数。如果不指定刷新次数,但指定了刷新时间间隔,这时刷新次数为无穷。 

    -d:显示磁盘相关统计信息。 

    -p:显示指定磁盘分区统计信息 

    -S:使用指定单位显示。参数有 k 、K 、m 、M ,分别代表1000、1024、1000000、1048576字节(byte)。默认单位为K(1024 bytes) 

    -V:显示vmstat版本信息。


    2.使用说明 

    例子1:每3秒输出一条结果

    字段说明: 

    Procs(进程): 

    r: The number of processes waiting for run time.运行队列中进程数量(等待获得CPU的进程数量),这个值也可以判断是否需要增加CPU。

    b: The number of processes in uninterruptible sleep.等待IO的进程数量。

     

    Memory(内存): 

    swpd: 使用虚拟内存大小 

    注意:如果swpd的值不为0,但是SI,SO的值长期为0,这种情况不会影响系统性能。

    free: 空闲物理内存大小

    buff: 用作缓冲的内存大小

    cache: 用作缓存的内存大小 

    注意:如果cache的值大的时候,说明cache处的文件数多,如果频繁访问到的文件都能被cache处,那么磁盘的读IO bi会非常小。

     

    Swap: 

    si: 每秒从交换区写到内存的大小,由磁盘调入内存

    so: 每秒写入交换区的内存大小,由内存调入磁盘 

    注意:内存够用的时候,这2个值都是0,如果这2个值长期大于0时,系统性能会受到影响,磁盘IO和CPU资源都会被消耗。有些朋友看到空闲内存(free)很少的或接近于0时,就认为内存不够用了,不能光看这一点,还要结合si和so,如果free很少,但是si和so也很少(大多时候是0),那么不用担心,系统性能这时不会受到影响的。

     

    IO:(现在的Linux版本块的大小为1kb) 

    bi: 每秒读取的块数

    bo: 每秒写入的块数 

    注意:随机磁盘读写的时候,这2个值越大(如超出1024k),能看到CPU在IO等待的值也会越大。

     

    系统: 

    in: 每秒中断数,包括时钟中断。

    cs: 每秒上下文切换数。 

    注意:上面2个值越大,会看到由内核消耗的CPU时间会越大。

     

    CPU(以百分比表示): 

    us: 用户进程执行时间百分比(usertime) 

    注意: us的值比较高时,说明用户进程消耗的CPU时间多,但是如果长期超50%的使用,那么我们就该考虑优化程序算法或者进行加速。 

    sy: 内核系统进程执行时间百分比(systemtime) 

    注意:sy的值高时,说明系统内核消耗的CPU资源多,这并不是良性表现,我们应该检查原因。 

    wa: IO等待时间百分比 

    注意:wa的值高时,说明IO等待比较严重,这可能由于磁盘大量作随机访问造成,也有可能磁盘出现瓶颈(块操作)。 

    id: 空闲时间百分比


    例子2:显示活跃和非活跃内存

    使用-a选项显示活跃和非活跃内存时,所显示的内容除增加inact和active外,其他显示内容与例子1相同。

     

    字段说明: 

    Memory(内存): 

    inact: 非活跃内存大小(当使用-a选项时显示)

    active: 活跃的内存大小(当使用-a选项时显示)

     

    总结: 

    目前说来,对于服务器监控有用处的度量主要有: 

    r(运行队列)

    pi(页导入)

    us(用户CPU)

    sy(系统CPU)

    id(空闲)

    注意:如果r经常大于4 ,且id经常少于40,表示cpu的负荷很重。如果bi,bo 长期不等于0,表示内存不足。

     

    通过VMSTAT识别CPU瓶颈:

    r(运行队列)展示了正在执行和等待CPU资源的任务个数。当这个值超过了CPU数目,就会出现CPU瓶颈了。 


    Linux下查看CPU核心数的命令:

    cat /proc/cpuinfo|grep processor|wc -l

     

    当r值超过了CPU个数,就会出现CPU瓶颈,解决办法大体几种: 

    1. 最简单的就是增加CPU个数和核数

    2. 通过调整任务执行时间,如大任务放到系统不繁忙的情况下进行执行,进尔平衡系统任务

    3. 调整已有任务的优先级

     

    通过vmstat识别CPU满负荷: 

    首先需要声明一点的是,vmstat中CPU的度量是百分比的。当us+sy的值接近100的时候,表示CPU正在接近满负荷工作。但要注意的是,CPU 满负荷工作并不能说明什么,Linux总是试图要CPU尽可能的繁忙,使得任务的吞吐量最大化。唯一能够确定CPU瓶颈的还是r(运行队列)的值。

     

    通过vmstat识别RAM瓶颈: 

    数据库服务器都只有有限的RAM,出现内存争用现象是Oracle的常见问题。

     

    首先用free查看RAM的数量:

    [oracle@oracle-db02 ~]$ free

    total      used       free    shared    buffers     cached

    Mem:      2074924    2071112       3812          0     40616    1598656

    -/+ buffers/cache:     431840   1643084

    Swap:     3068404     195804    2872600

     

    当内存的需求大于RAM的数量,服务器启动了虚拟内存机制,通过虚拟内存,可以将RAM段移到SWAP DISK的特殊磁盘段上,这样会出现虚拟内存的页导出和页导入现象,页导出并不能说明RAM瓶颈,虚拟内存系统经常会对内存段进行页导出,但页导入操作就表明了服务器需要更多的内存了,页导入需要从SWAP DISK上将内存段复制回RAM,导致服务器速度变慢。

     

    解决的办法有几种: 

    1. 最简单的,加大RAM;

    2. 改小SGA,使得对RAM需求减少;

    3. 减少RAM的需求。(如:减少PGA)

    展开全文
  • Linux内存使用统计

    2012-01-09 10:51:08
    今天写了一个Linux程序,用到了多个双向链表,估计由于释放问题导致内存占用过高,在网上找到比较好用的一个脚本,可以比较详细的统计Linux内存使用情况,现转载如下: #!/bin/sh #$Id: memuse.sh, v0.1 ...
  • 前言若操作系统的物理内存用完了,则就会用到swap(虚拟...操作系统无法正常运行,所以我们要高度重视内存使用,下面我们就来说一说,怎么统计哪些进程使用了swap分区,查看swap的方法有许多,下面我们就来一个个说明...
  • 前言若操作系统的物理内存用完了,则就会用到swap(虚拟内存)。...操作系统无法正常运行,所以我们要高度重视内存使用,下面我们就来说一说,怎么统计哪些进程使用了swap分区,查看swap的方法有许多,...
  • vmstat是一个查看虚拟内存(Virtual Memory)使用状况的工具。 2.使用格式 vmstat -option interval count 3.vmstat常用的选项 -a:显示活跃和非活跃内存 -f:显示从系统启动至今的fork数量 。 4.vmstat常用...
  • vmstat 是 Virtual Memory Statistics ( 虚拟内存统计 ) 的缩写,利用 vmstat 命令可以对操作系统的内存信息、进程状态和 CPU 活动等进行监视。但是只能对系统的整体情况进行统计,无法对某个进程进行深入分析。 ...
  • 转载一篇关于进程内存计算和CGROUP内存计算差异的...在Linux内核,对于进程的内存使用与Cgroup的内存使用统计有一些相同和不同的地方。 进程的内存统计 一般来说,业务进程使用的内存主要有以下几种情况: (1)用...
  • Understanding memory usage on Linux This entry is for those people who have ever wondered, "Why the hell is a simple KDE text editor taking up 25 megabytes of memory?" Many people are led to believe
  • Linux vmstat全称叫Virtual Memory Statistics; vmstat命令是最常见的Linux/Unix监控工具,可以展现给定时间间隔的服务器的状态值,包括服务器的CPU使用率,内存使用,虚拟内存交换情况,IO读写情况。这个命令是...
  • RAM 代表“随机访问内存(Random Access Memory)”,是一种计算机数据存储,它会存储经常使用的程序来提升系统性能。 什么是虚拟内存? 虚拟内存是一种内存管理方式,计算机通过临时将最近未使用的程序数据从 RAM 转移...
  • 查看系统状态vmstat[root@localhost~]#vmstat procs-----------memory-------------swap-------io------system-------cpu----- rbswpdfreebuffcachesisobiboincsus...
  • 近期由于公司的统计报表系统oracle load相当高,业务基本已经完了,呵呵。顺其便对oracle相关参数进行调整,要变更的参数如下:sga_target 原值:3g 新值:20gpga_aggregate_target...
  • 观察Linux 的性能

    千次阅读 2014-09-16 12:39:35
    Linux上基本的性能监测工具如下:1)top 或Htop,读取CPU,DRAM,Virtual Memory的信息,能够观察每个进程的状况,主要是CPU的使用情况2)iostat 读取Disk,IO控制器,块设备, 观察Disk 的IO统计数据3)mpsta
  • memory check

    2014-03-31 20:05:27
    关于物理内存的统计信息,可以通过/proc/phymem目录下的文件查看: 说明 /proc/phymem dist 显示物理内存使用分布信息 mem: 262144 kB |--mem_other: 15996 kB |--mem_linux: 246148 kB |--mem_reserved: ...
  • Understanding memory usage on Linux This entry is for those people who have ever wondered, "Why the hell is a simple KDE text editor taking up 25 megabytes of memory?" Many people are l...
  • linux命令

    2017-05-27 11:11:57
    查看CPU信息: cat /proc/cpuinfo (注意:processor是逻辑cpu) 查看内存信息: cat /proc/meminfo  虚拟内存统计信息工具:vmstat (virtual memory statistics)
  • 20191206 linux常用命令

    2019-12-06 10:21:56
    可用的memory=free memory+buffers+cached(可用内存的统计) 如何查看linux系统的内存和cpu信息? 文件:cpuinfo,meminfo,或者直接top命令。 如何查看正在运行的用户进程:进程名称,所占用端口号信息?netstat...
  • Linux vmstat详解

    2017-12-22 22:27:32
     vmstat - Report virtual memory statistics,从名字上来看这是一个虚拟内存统计报告工具,这个工具在Linux/unix中都是很常用的命令,相比top、ps等命令优势在于能输出整个Linux/Unix系统的资源使用情况,可以通过...
  • memory and swap accounting是 统计Linux内核的内存和交换区 为什么需要开启memory and swap? 这是docker官方提示的内容 Adjust memory and swap accounting When users run Docker, they may see these messages.....
  • time 用于统计命令执行所消耗的时间及相关系统资源等信息。time 可以显示的资源有四大项,分别是: Time resources Memory resources IO resources Command info 2.命令格式 time [options] command [arguments...]...
  • 查看linux 内存

    2018-03-14 15:06:00
    1.vmstat vmstat命令显示实时的和平均的统计,覆盖CPU、内存、I/O等内容。例如内存情况,不仅显示物理内存,也统计虚拟内存。  $ vmstat -s 2.top top命令提供了实时的运行中的程序的...Reported memory usage ...
  • centos 查看硬件配置 CPU more /proc/cpuinfo 可以找出 model name, CPU processor 的...Memory free -m 直接查看total部分知道时间可用的物理内存大小;Disk df -h 查看各挂载分区的大小和位置,自己统计大小;
  • Linux服务器性能优化

    千次阅读 2019-06-12 00:46:14
    vmstat(Virtual Memory Statistics 虚拟内存统计) 命令用来显示Linux系统虚拟内存状态,也可以报告关于进程、内存、I/O等系统整体运行状态。 用法 vmstat [-a] [-n] [-t] [-S unit] [delay [ count]] vmstat [-s] ...
  • linux命令:vmstat

    2019-06-17 09:26:00
    vmstat(Virtual Memory Statistics 虚拟内存统计) 命令用来显示Linux系统虚拟内存状态,也可以报告关于进程、内存、I/O等系统整体运行状态。 2、用法 vmstat [-a] [-n] [-t] [-S unit] [delay [ count]] vmstat...

空空如也

空空如也

1 2 3 4 5 ... 11
收藏数 215
精华内容 86
关键字:

linuxmemory统计

linux 订阅