大网数据广告活动
服务器运维问答

What does lower case "g" mean in top output?

· 52CE 我爱测

Can someone please help explain this, I have always used to interprete the "g" in top output to be size in Gigabytes even though the convention is to use uppercase "G" but now I am having second thoughts. I was monitoring my syst…

问题原文

原帖链接 · AguThadeus · CC BY-SA 4.0

Can someone please help explain this, I have always used to interprete the "g" in top output to be size in Gigabytes even though the convention is to use uppercase "G" but now I am having second thoughts.

I was monitoring my system memory usage when I found chrome using up to 1132.9g under VIRT column - an imposible amount of memory for the resources I have in my computer.

How can this be possible?

已采纳解答

原帖链接 · u1686_grawity · CC BY-SA 4.0

I have always used to interprete the "g" in top output to be size in Gigabytes even though the convention is to use uppercase "G" but now I am having second thoughts.

It's gigabytes. The procps-ng developers expect the user to choose between upper- and lower-case at compile time. Really.

I was monitoring my system memory usage when I found chrome using up to 1132.9g under VIRT column - an imposible amount of memory for the resources I have in my computer.

VIRT has no relationship with the resources you have in your computer. (Hence the name "virtual".) It represents virtual memory address space, and each region of virtual address space may be backed by actual RAM, but it may also be backed by something else – such as memory-mapped files, or nothing at all (a "fresh" RAM-backed anonymous mapping is not all reserved upfront; it only begins consuming RAM as it's dirtied).

In the case of web browsers, Chrome in particular, massive empty mappings may be used for JavaScript hardening similar to WebKit's GigaCage which Chrome also implements. As long as the mapping stays mostly untouched, it also mostly doesn't occupy any RAM – aside from a few kB or MB for the page table entries. (VSCode counts as a "web browser" here, as its Electron runtime is literally Chrome, and even "ng serve" – i.e. Node.js – uses the same JavaScript "V8" engine as Chrome does.) Finally for the GNOME Shell process, I suspect it's something to do with GPU VRAM access, although I'm not quite sure.

tl;dr you are looking at the wrong column. Just because it happens to count megabytes doesn't mean it's system memory usage.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2023-04-14)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。