你的位置:首页 > 软件开发 > 数据库 > MySQL 调优基础(二) Linux内存管理

MySQL 调优基础(二) Linux内存管理

发布时间:2015-10-01 17:00:02
进程的运行,必须使用内存。下图是Linux中进程中的内存的分布图:其中最重要的 heap segment 和 stack segment。其它内存段基本是大小固定的。注意stack是向低地址增长的,和heap相反。另外进程的内存地址从0开始,是因为使用的是虚拟内存。所以存在虚拟内 ...

进程的运行,必须使用内存。下图是Linux中进程中的内存的分布图:

MySQL 调优基础(二) Linux内存管理

其中最重要的 heap segment 和 stack segment。其它内存段基本是大小固定的。注意stack是向低地址增长的,和heap相反。另外进程的内存地址从0开始,是因为使用的是虚拟内存。所以存在虚拟内存到物理内存的映射。目前服务器一般都是64位的,32位的已经极少了,32为对内存有极大限制。

1. Linux 虚拟内存

Linux是通过虚拟内存的方式来管理内存的。虚拟内存和物理内存之间存在映射关系。当进程在CPU上运行时,虚拟内存就会映射到物理内存,供CPU来访问。

applications do not allocate physical memory, but request a memory map of a certain size at the Linux kernel and in exchange receive a map in virtual memory. As you can see, virtual memory does not necessarily have to be mapped into physical memory. If your application allocates a large amount of memory, some of it might be mapped to the swap file on the disk subsystem.

图示 进程虚拟内存 = 进程物理内存 + 进程swap(page out):

MySQL 调优基础(二) Linux内存管理

上图是top命令的截图,可以看到:mysqld 使用的虚拟内存为 735M,而常驻物理内存为 430M,所以其余的305M被swap out了(实际上是延迟分配)。

VIRT:The total amount of virtual memory used by the task. It includes all code, data and shared libraries plus pages that have been swapped out.

RES: Resident size (kb)。The non-swapped physical memory a task is using(常驻内存).

Linux handles the memory resource far more efficiently. The default configuration of the virtual memory manager allocates all available free

原标题:MySQL 调优基础(二) Linux内存管理

关键词:MYSQL

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。