linux 容器管理内存,linux – 我的容器的内存在哪里?

我有一个容器泄漏内存.或者至少,报告的内存消耗快速上升.如果我跑顶,我得到这个:

top - 16:56:51 up 6 days,17:25,0 users,load average: 0.16,0.27,0.31

Tasks: 4 total,1 running,3 sleeping,0 stopped,0 zombie

%cpu(s): 1.3 us,0.7 sy,0.0 ni,98.0 id,0.0 wa,0.0 hi,0.0 si,0.0 st

KiB Mem: 7676380 total,4089380 used,3587000 free,675164 buffers

KiB Swap: 0 total,0 used,0 free. 2586496 cached Mem

PID USER PR NI VIRT RES SHR S %cpu %MEM TIME+ COMMAND

1 root 20 0 46924 15196 6456 S 0.0 0.2 0:15.54 supervisord

8 root 20 0 3526084 47976 29660 S 0.0 0.6 0:59.15 dotnet

568 root 20 0 20364 3332 2728 S 0.0 0.0 0:00.09 bash

2800 root 20 0 21956 2420 2032 R 0.0 0.0 0:00.00 top

我此时报告的数字是90M,但没有加起来.我很确定/sys/fs/cgroup/memory/memory.usage_in_bytes是报道的内容:

> cd /sys/fs/cgroup/memory/

> cat cgroup.procs

1

8

568

2494

> cat memory.usage_in_bytes

92282880

> pmap -p 1 | tail -n 1

total 46924K

> pmap -p 8 | tail -n 1

total 3599848K

> pmap -p 568 | tail -n 1

total 20364K

> ps 2494

PID TTY STAT TIME COMMAND

在我看来,这里有大量内存“缺失”……如果我在输入内容时再次使用memory.usage_in_bytes:

> cat memory.usage_in_bytes

112291840

> pmap -p 1 | tail -n 1

total 46924K

> pmap -p 8 | tail -n 1

total 3452320K

> pmap -p 568 | tail -n 1

total 20368K

没有什么能明显解释这种内存使用情况.如果我看看memory.stat,我看到了这个:

# cat memory.stat

cache 89698304

RSS 30699520

RSS_huge 0

mapped_file 1552384

writeback 0

pgpgin 102007

pgpgout 72613

pgfault 115021

pgmajfault 8

inactive_anon 1519616

active_anon 30789632

inactive_file 417792

active_file 87654400

unevictable 4096

hierarchical_memory_limit 18446744073709551615

total_cache 89698304

total_RSS 30699520

total_RSS_huge 0

total_mapped_file 1552384

total_writeback 0

total_pgpgin 102007

total_pgpgout 72613

total_pgfault 115021

total_pgmajfault 8

total_inactive_anon 1519616

total_active_anon 30789632

total_inactive_file 417792

total_active_file 87654400

total_unevictable 4096

然后片刻之后:

# cat memory.stat

cache 89972736

RSS 30777344

RSS_huge 0

mapped_file 1552384

writeback 0

pgpgin 102316

pgpgout 72836

pgfault 115674

pgmajfault 8

inactive_anon 1519616

active_anon 30867456

inactive_file 417792

active_file 87928832

unevictable 4096

hierarchical_memory_limit 18446744073709551615

total_cache 89972736

total_RSS 30777344

total_RSS_huge 0

total_mapped_file 1552384

total_writeback 0

total_pgpgin 102316

total_pgpgout 72836

total_pgfault 115674

total_pgmajfault 8

total_inactive_anon 1519616

total_active_anon 30867456

total_inactive_file 417792

total_active_file 87928832

total_unevictable 4096

但我会说实话;我真的不知道我在这看什么.我怀疑地看着active_file但是又一次;我真的不知道我在看什么.

一些注意事项和观察:

>容器由Kubernetes安排.

>该程序将大量数据写入stdout.

>将写入控制台的数据量减少到接近零可以解决报告的内存泄漏问题.

>部署只向stdout写入大量数据的程序似乎没有表现出相同的内存泄漏(!)

所以!我该如何去寻找这个记忆被消耗的地方?对任何人来说有什么明显的东西 – 也许是某种东西盯着我的脸,或者我不是在看我应该做的事情?

谢谢!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值