热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Linux内存管理中的RSS和VSZ是什么-WhatisRSSandVSZinLinuxmemorymanagement

WhatareRSSandVSZinLinuxmemorymanagement?Inamultithreadedenvironmenthowcanbothofthes

What are RSS and VSZ in Linux memory management? In a multithreaded environment how can both of these can be managed and tracked?

Linux内存管理中的RSS和VSZ是什么?在多线程环境中,如何管理和跟踪这两者?

4 个解决方案

#1


312  

RSS is the Resident Set Size and is used to show how much memory is allocated to that process and is in RAM. It does not include memory that is swapped out. It does include memory from shared libraries as long as the pages from those libraries are actually in memory. It does include all stack and heap memory.

RSS是常驻设置大小,用于显示为该进程分配了多少内存,并在RAM中。它不包括被交换出去的内存。它确实包括共享库中的内存,只要这些库中的页面实际上在内存中。它包括所有堆栈和堆内存。

VSZ is the Virtual Memory Size. It includes all memory that the process can access, including memory that is swapped out, memory that is allocated, but not used, and memory that is from shared libraries.

VSZ是虚拟内存大小。它包括进程可以访问的所有内存,包括交换出去的内存、分配但不使用的内存和来自共享库的内存。

So if process A has a 500K binary and is linked to 2500K of shared libraries, has 200K of stack/heap allocations of which 100K is actually in memory (rest is swapped or unused), and it has only actually loaded 1000K of the shared libraries and 400K of its own binary then:

如果处理一个有500 k二进制和共享库与2500 k,200 k的堆栈和堆分配的100 k实际上是在内存中(其他交换或未使用),实际上它只有加载共享库的1000 k和400 k的二进制文件:

RSS: 400K + 1000K + 100K = 1500K
VSZ: 500K + 2500K + 200K = 3200K

Since part of the memory is shared, many processes may use it, so if you add up all of the RSS values you can easily end up with more space than your system has.

由于内存的一部分是共享的,所以许多进程可能会使用它,所以如果您将所有的RSS值加起来,您很容易得到比系统拥有的更多的空间。

The memory that is allocated also may not be in RSS until it is actually used by the program. So if your program allocated a bunch of memory up front, then uses it over time, you could see RSS going up and VSZ staying the same.

被分配的内存也可能在程序实际使用之前不在RSS中。如果你的程序预先分配了一堆内存,然后随着时间的推移使用它,你可以看到RSS在增加VSZ保持不变。

There is also PSS (proportional set size). This is a newer measure which tracks the shared memory as a proportion used by the current process. So if there were two processes using the same shared library from before:

还有PSS(比例设置大小)。这是一个更新的度量,它跟踪共享内存作为当前进程使用的比例。因此,如果以前有两个进程使用相同的共享库:

PSS: 400K + (1000K/2) + 100K = 400K + 500K + 100K = 1000K

Threads all share the same address space, so the RSS, VSZ and PSS for each thread is identical to all of the other threads in the process. Use ps or top to view this information in linux/unix.

线程都共享相同的地址空间,因此每个线程的RSS、VSZ和PSS与进程中的所有其他线程相同。在linux/unix中使用ps或top查看这些信息。

There is way more to it than this, to learn more check the following references:

还有比这更重要的事情,去了解更多关于以下参考文献的信息:

  • http://manpages.ubuntu.com/manpages/en/man1/ps.1.html
  • http://manpages.ubuntu.com/manpages/en/man1/ps.1.html
  • https://web.archive.org/web/20120520221529/http://emilics.com/blog/article/mconsumption.html
  • https://web.archive.org/web/20120520221529/http:/ /emilics.com/blog/article/mconsumption.html

Also see:

还看到:

  • A way to determine a process's "real" memory usage, i.e. private dirty RSS?
  • 确定进程“真实”内存使用情况的一种方法,即私有的脏RSS?

#2


39  

RSS is Resident Set Size (physically resident memory - this is currently occupying space in the machine's physical memory), and VSZ is Virtual Memory Size (address space allocated - this has addresses allocated in the process's memory map, but there isn't necessarily any actual memory behind it all right now).

RSS是常驻设置大小(物理驻留内存——这是当前占用机器物理内存中的空间),VSZ是虚拟内存大小(分配的地址空间——它在进程的内存映射中分配了地址,但是现在它后面不一定有任何实际的内存)。

Note that in these days of commonplace virtual machines, physical memory from the machine's view point may not really be actual physical memory.

请注意,在这些常见的虚拟机的时代,从机器视图的物理内存可能不是真正的物理内存。

#3


4  

I think much has already been said, about RSS vs VSZ. From an administrator/programmer/user perspective, when I design/code applications I am more concerned about the RSZ, (Resident memory), as and when you keep pulling more and more variables (heaped) you will see this value shooting up. Try a simple program to build malloc based space allocation in loop, and make sure you fill data in that malloc'd space. RSS keeps moving up. As far as VSZ is concerned, it's more of virtual memory mapping that linux does, and one of its core features derived out of conventional operating system concepts. The VSZ management is done by Virtual memory management of the kernel, for more info on VSZ, see Robert Love's description on mm_struct and vm_struct, which are part of basic task_struct data structure in kernel.

我认为关于RSS vs VSZ已经说了很多。从管理员/程序员/用户的角度来看,当我设计/编写应用程序时,我更关心RSZ(驻留内存),当您不断地拉出越来越多的变量(堆起来)时,您将看到这个值的激增。尝试一个简单的程序在循环中构建基于malloc的空间分配,并确保在该malloc的空间中填充数据。RSS不断上升。就VSZ而言,它更多的是linux所做的虚拟内存映射,它的核心功能之一源自传统的操作系统概念。VSZ管理由内核的虚拟内存管理完成,有关VSZ的更多信息,请参见Robert Love对mm_struct和vm_struct的描述,这是内核中基本task_struct数据结构的一部分。

#4


0  

They are not managed, but measured and possibly limited (see getrlimit system call, also on getrlimit(2)).

它们不是被管理的,而是被度量的,并且可能是有限的(参见getrlimit system调用,也在getrlimit(2)上)。

RSS means resident set size (the part of your virtual address space sitting in RAM).

RSS意味着驻留的设置大小(您的虚拟地址空间的一部分位于RAM中)。

You can query the virtual address space of process 1234 using proc(5) with cat /proc/1234/maps and its status (including memory consumption) thru cat /proc/1234/status

您可以使用proc(5)查询进程1234的虚拟地址空间,并通过cat /proc/1234/maps及其状态(包括内存消耗)查询进程1234的虚拟地址空间


推荐阅读
  • 在Docker中,将主机目录挂载到容器中作为volume使用时,常常会遇到文件权限问题。这是因为容器内外的UID不同所导致的。本文介绍了解决这个问题的方法,包括使用gosu和suexec工具以及在Dockerfile中配置volume的权限。通过这些方法,可以避免在使用Docker时出现无写权限的情况。 ... [详细]
  • 本文介绍了数据库的存储结构及其重要性,强调了关系数据库范例中将逻辑存储与物理存储分开的必要性。通过逻辑结构和物理结构的分离,可以实现对物理存储的重新组织和数据库的迁移,而应用程序不会察觉到任何更改。文章还展示了Oracle数据库的逻辑结构和物理结构,并介绍了表空间的概念和作用。 ... [详细]
  • Webmin远程命令执行漏洞复现及防护方法
    本文介绍了Webmin远程命令执行漏洞CVE-2019-15107的漏洞详情和复现方法,同时提供了防护方法。漏洞存在于Webmin的找回密码页面中,攻击者无需权限即可注入命令并执行任意系统命令。文章还提供了相关参考链接和搭建靶场的步骤。此外,还指出了参考链接中的数据包不准确的问题,并解释了漏洞触发的条件。最后,给出了防护方法以避免受到该漏洞的攻击。 ... [详细]
  • 本文介绍了Linux系统中正则表达式的基础知识,包括正则表达式的简介、字符分类、普通字符和元字符的区别,以及在学习过程中需要注意的事项。同时提醒读者要注意正则表达式与通配符的区别,并给出了使用正则表达式时的一些建议。本文适合初学者了解Linux系统中的正则表达式,并提供了学习的参考资料。 ... [详细]
  • Ubuntu 9.04中安装谷歌Chromium浏览器及使用体验[图文]
    nsitionalENhttp:www.w3.orgTRxhtml1DTDxhtml1-transitional.dtd ... [详细]
  • 本文介绍了一些Java开发项目管理工具及其配置教程,包括团队协同工具worktil,版本管理工具GitLab,自动化构建工具Jenkins,项目管理工具Maven和Maven私服Nexus,以及Mybatis的安装和代码自动生成工具。提供了相关链接供读者参考。 ... [详细]
  • 如何自行分析定位SAP BSP错误
    The“BSPtag”Imentionedintheblogtitlemeansforexamplethetagchtmlb:configCelleratorbelowwhichi ... [详细]
  • Linuxchmod目录权限命令图文详解在Linux文件系统模型中,每个文件都有一组9个权限位用来控制谁能够读写和执行该文件的内容。对于目录来说,执行位的作用是控制能否进入或者通过 ... [详细]
  • EPICS Archiver Appliance存储waveform记录的尝试及资源需求分析
    本文介绍了EPICS Archiver Appliance存储waveform记录的尝试过程,并分析了其所需的资源容量。通过解决错误提示和调整内存大小,成功存储了波形数据。然后,讨论了储存环逐束团信号的意义,以及通过记录多圈的束团信号进行参数分析的可能性。波形数据的存储需求巨大,每天需要近250G,一年需要90T。然而,储存环逐束团信号具有重要意义,可以揭示出每个束团的纵向振荡频率和模式。 ... [详细]
  • 如何去除Win7快捷方式的箭头
    本文介绍了如何去除Win7快捷方式的箭头的方法,通过生成一个透明的ico图标并将其命名为Empty.ico,将图标复制到windows目录下,并导入注册表,即可去除箭头。这样做可以改善默认快捷方式的外观,提升桌面整洁度。 ... [详细]
  • android listview OnItemClickListener失效原因
    最近在做listview时发现OnItemClickListener失效的问题,经过查找发现是因为button的原因。不仅listitem中存在button会影响OnItemClickListener事件的失效,还会导致单击后listview每个item的背景改变,使得item中的所有有关焦点的事件都失效。本文给出了一个范例来说明这种情况,并提供了解决方法。 ... [详细]
  • 禁止程序接收鼠标事件的工具_VNC Viewer for Mac(远程桌面工具)免费版
    VNCViewerforMac是一款运行在Mac平台上的远程桌面工具,vncviewermac版可以帮助您使用Mac的键盘和鼠标来控制远程计算机,操作简 ... [详细]
  • 推荐系统遇上深度学习(十七)详解推荐系统中的常用评测指标
    原创:石晓文小小挖掘机2018-06-18笔者是一个痴迷于挖掘数据中的价值的学习人,希望在平日的工作学习中,挖掘数据的价值, ... [详细]
  • 【MicroServices】【Arduino】装修甲醛检测,ArduinoDart甲醛、PM2.5、温湿度、光照传感器等,数据记录于SD卡,Python数据显示,UI5前台,微服务后台……
    这篇文章介绍了一个基于Arduino的装修甲醛检测项目,使用了ArduinoDart甲醛、PM2.5、温湿度、光照传感器等硬件,并将数据记录于SD卡,使用Python进行数据显示,使用UI5进行前台设计,使用微服务进行后台开发。该项目还在不断更新中,有兴趣的可以关注作者的博客和GitHub。 ... [详细]
  • 本文详细介绍了MySQL表分区的创建、增加和删除方法,包括查看分区数据量和全库数据量的方法。欢迎大家阅读并给予点评。 ... [详细]
author-avatar
GZJYGZJYGZJY
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有