- 浏览: 480020 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
alvin198761:
renzhengzhi 写道我参与过12306余票查询系统的开 ...
别给12306 辩解了 -
renzhengzhi:
我参与过12306余票查询系统的开发,用户请求被前面3层缓存拦 ...
别给12306 辩解了 -
renzhengzhi:
写的很好。
JAVA线程dump的分析 -
liyonghui160com:
说好的附件呢
分布式服务框架 Zookeeper -- 管理分布式环境中的数据 -
ghpaas:
orbeon作为xforms标准的实现,不论其设计器还是运行时 ...
XForms 1.1 中文翻译—第1章 关于XForms标准
HOWTO: Profile Memory in a Linux System
1. Introduction
It's important to determine how your system utilizes it's
resources. If your systems performance is unacceptable, it is
necessary to determine which resource is slowing the system
down. This document attempts to identify the following:
a. What is the system memory usage per unit time?
b. How much swap is being used per unit time?
c. What does each process' memory use look like over time?
d. What processes are using the most memory?
I used a RedHat-7.3 machine (kernel-2.4.18) for my experiments,
but any modern Linux distribution with the commands "ps" and
"free" would work.
2. Definitions
RAM (Random Access Memory) - Location where programs reside when
they are running. Other names for this are system memory or
physical memory. The purpose of this document is to determine if
you have enough of this.
Memory Buffers - A page cache for the virtual memory system. The
kernel keeps track of frequently accessed memory and stores the
pages here.
Memory Cached - Any modern operating system will cache files
frequently accessed. You can see the effects of this with the
following commands:
for i in 1 2 ; do
free -o
time grep -r foo /usr/bin >/dev/null 2>/dev/null
done
Memory Used - Amount of RAM in use by the computer. The kernel
will attempt to use as much of this as possible through buffers
and caching.
Swap - It is possible to extend the memory space of the computer
by using the hard drive as memory. This is called swap. Hard
drives are typically several orders of magnitude slower than RAM
so swap is only used when no RAM is available.
Swap Used - Amount of swap space used by the computer.
PID (Process IDentifier) - Each process (or instance of a running
program) has a unique number. This number is called a PID.
PPID (Parent Process IDentifier) - A process (or running program)
can create new processes. The new process created is called a
child process. The original process is called the parent
process. The child process has a PPID equal to the PID of the
parent process. There are two exceptions to this rule. The first
is a program called "init". This process always has a PID of 1 and
a PPID of 0. The second exception is when a parent process exit
all of the child processes are adopted by the "init" process and
have a PPID of 1.
VSIZE (Virtual memory SIZE) - The amount of memory the process is
currently using. This includes the amount in RAM and the amount in
swap.
RSS (Resident Set Size) - The portion of a process that exists in
physical memory (RAM). The rest of the program exists in swap. If
the computer has not used swap, this number will be equal to
VSIZE.
3. What consumes System Memory?
The kernel - The kernel will consume a couple of MB of memory. The
memory that the kernel consumes can not be swapped out to
disk. This memory is not reported by commands such as "free" or
"ps".
Running programs - Programs that have been executed will consume
memory while they run.
Memory Buffers - The amount of memory used is managed by the
kernel. You can get the amount with "free".
Memory Cached - The amount of memory used is managed by the
kernel. You can get the amount with "free".
4. Determining System Memory Usage
The inputs to this section were obtained with the command:
free -o
The command "free" is a c program that reads the "/proc"
filesystem.
There are three elements that are useful when determining the
system memory usage. They are:
a. Memory Used
b. Memory Used - Memory Buffers - Memory Cached
c. Swap Used
A graph of "Memory Used" per unit time will show the "Memory Used"
asymptotically approach the total amount of memory in the system
under heavy use. This is normal, as RAM unused is RAM wasted.
A graph of "Memory Used - Memory Buffered - Memory Cached" per
unit time will give a good sense of the memory use of your
applications minus the effects of your operating system. As you
start new applications, this value should go up. As you quit
applications, this value should go down. If an application has a
severe memory leak, this line will have a positive slope.
A graph of "Swap Used" per unit time will display the swap
usage. When the system is low on RAM, a program called kswapd will
swap parts of process if they haven't been used for some time. If
the amount of swap continues to climb at a steady rate, you may
have a memory leak or you might need more RAM.
5. Per Process Memory Usage
The inputs to this section were obtained with the command:
ps -eo pid,ppid,rss,vsize,pcpu,pmem,cmd -ww --sort=pid
The command "ps" is a c program that reads the "/proc"
filesystem.
There are two elements that are useful when determining the per
process memory usage. They are:
a. RSS
b. VSIZE
A graph of RSS per unit time will show how much RAM the process is
using over time.
A graph of VSIZE per unit time will show how large the process is
over time.
6. Collecting Data
a. Reboot the system. This will reset your systems memory use
b. Run the following commands every ten seconds and redirect the
results to a file.
free -o
ps -eo pid,ppid,rss,vsize,pcpu,pmem,cmd -ww --sort=pid
c. Do whatever you normally do on your system
d. Stop logging your data
7. Generate a Graph
a. System Memory Use
For the output of "free", place the following on one graph
1. X-axis is "MB Used"
2. Y-axis is unit time
3. Memory Used per unit time
4. Memory Used - Memory Buffered - Memory Cached per unit time
5. Swap Used per unit time
b. Per Process Memory Use
For the output of "ps", place the following on one graph
1. X-axis is "MB Used"
2. Y-axis is unit time
3. For each process with %MEM > 10.0
a. RSS per unit time
b. VSIZE per unit time
8. Understand the Graphs
a. System Memory Use
"Memory Used" will approach "Memory Total"
If "Memory Used - Memory Buffered - Memory Cached" is 75% of
"Memory Used", you either have a memory leak or you need to
purchase more memory.
b. Per Process Memory Use
This graph will tell you what processes are hogging the
memory.
If the VSIZE of any of these programs has a constant, positive
slope, it may have a memory leak.
发表评论
-
使用 RPM 打包软件,第 1 部分: 构建和分发包
2012-03-26 10:31 1253顾名思义,开源软件 ... -
用 RPM 打包软件,第 3 部分
2012-03-26 10:30 1153安装和卸载脚本的工作原理 安装和卸载脚本看起来很简单, ... -
用 RPM 打包软件,第 2 部分
2012-03-26 10:28 1153不作为 root 用户来构建 RPM 包 正如您在第 1 ... -
用 RPM 打包软件,第 1 部分
2012-03-26 10:23 978RPM(Red Hat Package Manager)是用于 ... -
Memory usage analysis
2010-09-03 23:33 1210Memory usage analysis Syste ... -
Linux: How to measure actual memory usage of an application or process?
2010-09-03 23:31 1277http://stackoverflow.com/questi ... -
Linux内存管理机制
2010-09-03 22:48 2087内存是Linux内核所管理的最重要的资源之一,内存管理 ... -
linux内存管理概述
2010-09-03 22:44 2445Linux中的地址空间(一)有这么一系列的问题,是否在困扰 ... -
linux上buffer和cache的区别
2010-09-03 15:14 1520free free 命令相对于top 提供了更简洁的查看系统 ... -
linux下top命令参数解释
2010-09-03 14:56 864top命令是Linux下常用的性能分析工具,能够实时显示系统中 ... -
smem memory reporting tool
2010-08-25 15:41 968smem is a tool that can give ... -
Linux进程虚拟内存和物理内存
2010-08-25 15:39 5047先介绍几个基本概念: SIZE: 进程使用的 ... -
Memory: VSS/RSS/PSS/USS
2010-08-25 13:54 1529Terms VSS - Virtual Set ... -
Linux 内核的文件 Cache 管理机制介绍
2010-08-18 18:21 10501 前言 自从诞生以来,Linux 就被不断完善和普及 ... -
运行时: 块内存复制,第 2 部分
2010-08-06 12:33 1237我的 前一专栏专注于 ... -
RunTime: 块内存复制
2010-08-06 12:32 1180内存复制 在计算机中,内存复制经常而普遍。它们出现在联网 ... -
内存详解
2010-08-06 11:34 931文档选项 ... -
Linux slab 分配器剖析
2010-08-06 11:32 1314良好的操作系统性能部分依赖于操作系统有效管理资源的能力。在 ... -
降低 Linux 内存开销
2010-08-06 11:30 1100Linux 广受追捧的一个优点是它比 Microsoft® ... -
在 Linux 平台中调试 C/C++ 内存泄漏方法
2010-08-06 11:29 1820由于 C 和 C++ 程序中完全由程序员自主申请和释放内存 ...
相关推荐
The benefit of a column maker is that it can help you to format your text/code, or in some cases to make it easier to read in complex nested logic. Quick Open UltraEdit and UEStudio provide multiple ...
architecture profile, ARMv8-A, that defines a Virtual Memory System Architecture (VMSA). • The programmers’ model, and its interfaces to System registers that control most PE and memory system ...
In this chapter, you'll learn additional ways DTrace can profile code, as well as how to augment existing code without laying a finger on the actual executable itself. 27. DTrace vs objc_msgSend In ...
For the most part any apk in /system/framework on a device will be a framework file. On some devices they might reside in /data/system-framework and even cleverly hidden in /system/app or /system/priv...
I deferred from testing the get test over 100 million record as it would require a huge array in memory to store the Guid keys for finding later, that is why there is a NT (not tested) in the table. ...
A later revision of this specification may specify a particular normalization form." In other words, if you want to use NFS4 you might find the conversion and normalization features of convmv quite ...
Profile-Guided or Other Optimizations Section 11.6. Debugging Optimized Programs Section 11.7. Recursion for Fibonacci Numbers Revisited Summary References Exercises Chapter 12. ...
traycalendar.zip A simple app that places a date in the system tray(62KB)<END><br>14,lineprint.zip A line printer class(37KB)<END><br>15,PrintMechanism_src.zip Learn how to implement print ...
10.8.5. Fetching a Rowset via a Many-to-many Relationship 10.8.6. Cascading Write Operations 10.8.6.1. Notes Regarding Cascading Operations 11. Zend_Debug 11.1. 输出变量的值 (Dumping Variables) 12...
Embedded In-memory LDAP Server 30.10. InfluxDB 30.10.1. Connecting to InfluxDB 31. Caching 31.1. Supported Cache Providers 31.1.1. Generic 31.1.2. JCache (JSR-107) 31.1.3. EhCache 2.x 31.1.4. ...
In this dissertation, we introduce a weighting scheme and a penalty function to address the above issue. Experiment results show that improved similarity model can significantly improve the ...
RTL819X系列的芯片方案,SDK开发指导手册。 1. Introduction .................................................................................................................................7 ...