我有一个在 k8s 上运行的 java 进程。
\n我设置Xms和Xmx来处理。
\njava -Xms512M -Xmx1G -XX:SurvivorRatio=8 -XX:NewRatio=6 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSParallelRemarkEnabled -jar automation.jar\n
Run Code Online (Sandbox Code Playgroud)\n我的预期是 pod 应该消耗 1.5 或 2 GB 内存,但它消耗的内存更多,接近 3.5 GB。太多了。\n如果 \xc4\xb1 在虚拟机上运行我的进程,它消耗的内存要少得多。
\n当 \xc4\xb1 检查 pod 的内存统计信息时,\xc4\xb1 表示 pod 分配了过多的缓存内存。
\nRSS近1.5GB就可以了。因为Xmx是1gb。但为什么缓存近3GB。
\n有什么方法可以调整或控制这种用法吗?
\n/app $ cat /sys/fs/cgroup/memory/memory.stat\ncache 2881228800\nrss 1069154304\nrss_huge 446693376\nmapped_file 1060864\nswap 831488\npgpgin 1821674\npgpgout 966068\npgfault 467261\npgmajfault 47\ninactive_anon 532504576\nactive_anon 536588288\ninactive_file 426450944\nactive_file 2454777856\nunevictable 0\nhierarchical_memory_limit 16657932288\nhierarchical_memsw_limit 9223372036854771712\ntotal_cache 2881228800\ntotal_rss 1069154304\ntotal_rss_huge 446693376\ntotal_mapped_file 1060864\ntotal_swap 831488\ntotal_pgpgin 1821674\ntotal_pgpgout 966068\ntotal_pgfault 467261\ntotal_pgmajfault 47\ntotal_inactive_anon 532504576\ntotal_active_anon 536588288\ntotal_inactive_file 426450944\ntotal_active_file 2454777856\ntotal_unevictable 0\n
Run Code Online (Sandbox Code Playgroud)\n