linux - 运行时虚拟内存的大小

标签 linux

我创建了一个应用程序,当我使用 size 检查时,其大小显示为

  admin@pc:~/Desktop$ size u
  text     data     bss     dec     hex  filename  
  1725     552       16    2293     8f5   u

在运行时使用 ps -au 检查时

admin@pc:~/Desktop$ ps -au  
USER    PID    %CPU %MEM  VSZ    RSS TTY      STAT START   TIME COMMAND  
admin   16730  0.0  0.0   3876   448 pts/2    S+   15:48   0:00 ./u  
admin   16731  0.0  0.0   3876   252 pts/2    S+   15:48   0:00 ./u
  1. 为什么它显示的虚拟内存大小与我们使用 size 命令看到的不同。 .即为什么 2293 与 ps -au 看到的 VSZ (3876) 不同?
  2. 由于虚拟内存的大小非常小,它可以累积在 4k 字节的单个页面框架 (RAM/RSS) 中。这意味着,由于 2293 字节小于 4096 字节,整个过程可以加载到单个帧中。那为什么RSS 448和252小于2293或3876呢?

最佳答案

why is it showing different size of virtual memory as we saw using size command. .i.e why 2293 is different from VSZ (3876) as seen by ps -au?

堆栈和堆不存储在二进制文件中,它们仅在运行时创建。这就是为什么二进制文件的 textdatabss 部分的大小加起来不等于 VSZ 的原因。

As size of virtual memory is very less, it can be accumulate in single page frame(RAM/RSS) of 4k byte. It means, whole process can be loaded into single frame as 2293 byte is less than 4096 byte. Then why is RSS 448 and 252 less than 2293 or 3876?

VSZ 以 1024 字节为单位报告。也就是说3876代表3969024字节。

关于linux - 运行时虚拟内存的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17919062/

相关文章:

linux - 在 Linux 上显示当前分支和颜色(类似于 Windows 上的 Git Bash)

c++ - 可执行文件中定义的函数名称(使用 dladdr)

Linux:bash 脚本中的 sendmail

c - 等待来自多个进程的信号时 sigwait 有什么问题

linux - Linux 中 .txt 文件的分组依据和求和

linux - Bash 用另一个字符串替换空格和字符串结尾

linux - zabbix 前端 web 界面给出错误 404 (ubuntu server 14.04)

linux - 如何将所有 postgres 权限授予我的本地用户?

linux - 错误文档 403 不适用于子目录

linux - 使用 linux shell 显示目录中的最新文件