我创建了一个应用程序,当我使用 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
- 为什么它显示的虚拟内存大小与我们使用 size 命令看到的不同。 .即为什么 2293 与
ps -au
看到的 VSZ (3876) 不同? - 由于虚拟内存的大小非常小,它可以累积在 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?
堆栈和堆不存储在二进制文件中,它们仅在运行时创建。这就是为什么二进制文件的 text
、data
和 bss
部分的大小加起来不等于 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/