最初,我尝试通过生成多进程来避免 lxml 内存泄漏并终止它,但失败了。
因此,在尝试新想法之前,我在服务文件中设置OOMPolicy=stop
, 。MemoryMax=2G
我的意图是,如果 podman stats 中的内存使用量达到 2G,systemd 的 OOM-killer 会发送 stop(而不是来自内核的 SIGKILL)。所以它将重新启动。
然而,内存使用量podman stats
是164.9MB
,但systemctl status
结果是Memory: 756.0K (high: 1.8G max: 2.0G available: 1.8G)
。(你可以忽略高。我刚刚尝试过--runtime
。)
当然,实验会显示一些东西,但我想听听关于内存的解释..因为unix会有我还不明白的行为原因。
$podman stats
ID NAME CPU % MEM USAGE / LIMIT MEM % NET IO BLOCK IO PIDS CPU TIME AVG CPU %
254d65607347 memory_leaking_lxml_container 0.09% 164.9MB / 33.29GB 0.50% 40.84MB / 2.479MB 0B / 0B 14 21.501493s 0.84%
$systemctl status --user container-memory_leaking_lxml_container.service
● container-memory_leaking_lxml_container.service - Podman container-memory_leaking_lxml_container.service
Loaded: loaded (/home/shelf/.config/systemd/user/container-memory_leaking_lxml_container.service; enabled; preset: disabled)
Drop-In: /run/user/1000/systemd/user.control/container-memory_leaking_lxml_container.service.d
└─50-MemoryHigh.conf
Active: active (running) since Thu 2023-10-26 02:43:46 KST; 13s ago
Docs: man:podman-generate-systemd(1)
Main PID: 10403 (conmon)
Tasks: 1 (limit: 202744)
Memory: 756.0K (high: 1.8G max: 2.0G available: 1.8G)
CPU: 88ms
CGroup: /user.slice/user-1000.slice/[email protected]/app.slice/container-memory_leaking_lxml_container.service
└─10403 /usr/bin/conmon --api-version 1 -c 6a4a037a7cca7641188ea145446e8fac2ba6a76ccf81ebce7a9d52cb80e31265 -u 6a4a037a7cca7641188ea145446e8fac2ba6a76ccf81ebce7a9d52cb80e31265 -r /usr/bin/crun -b /home/shelf/.local/share/cont>
另一种情况是“42.84MB”和“80.9M”
af8cfa352332 taskwarrior-webui 0.01% 42.84MB / 12.26GB 0.35% 2.42kB / 430B 0B / 0B 23 959.476ms 0.01%
[shelf@localhost ~]$ systemctl --user status container-taskwarrior-webui.service
● container-taskwarrior-webui.service - Podman container-287516d806e5dec732bb2152568304950343e98c75cd05f8ade36826a2d292e2.service
Loaded: loaded (/home/shelf/.config/systemd/user/container-taskwarrior-webui.service; enabled; preset: disabled)
Active: active (running) since Thu 2023-10-26 01:19:24 KST; 2h 19min ago
Docs: man:podman-generate-systemd(1)
Main PID: 1801 (conmon)
Tasks: 16 (limit: 74601)
Memory: 80.9M
CPU: 695ms
CGroup: /user.slice/user-1000.slice/[email protected]/app.slice/container-taskwarrior-webui.service
├─1735 /usr/bin/slirp4netns --disable-host-loopback --mtu=65520 --enable-sandbox --enable-seccomp --enable-ipv6 -c -e 3 -r 4 --netns-type=path /run/user/1000/netns/netns-cb5acc65-4f8a-650e-6ae6-68e4fc909e11 tap0
├─1738 rootlessport
├─1745 rootlessport-child
├─1777 /usr/bin/fuse-overlayfs -o "lowerdir=/home/shelf/.local/share/containers/storage/overlay/l/24YP66TL5NQBZOG6ZSFAGPT42L:/home/shelf/.local/share/containers/storage/overlay/l/6OIWR3J24EEIAHQS7UBWPF6XQ4:/home>
└─1801 /usr/bin/conmon --api-version 1 -c af8cfa352332489ffaa29c82efd7ecf6e6dbb0d90705be6b559203a7f45bb8a0 -u af8cfa352332489ffaa29c82efd7ecf6e6dbb0d90705be6b559203a7f45bb8a0 -r /usr/bin/crun -b /home/shelf/.local/shar>
Oct 26 01:19:23 localhost.localdomain podman[1636]: 2023-10-26 01:19:23.144002301 +0900 KST m=+1.152343622 container create af8cfa352332489ffaa29c82efd7ecf6e6dbb0d90705be6b559203a7f45bb8a0 (image=docker.io/dcsunset/taskwarrior-webui:lates>
Oct 26 01:19:24 localhost.localdomain podman[1636]: 2023-10-26 01:19:24.368842932 +0900 KST m=+2.377184246 container init af8cfa352332489ffaa29c82efd7ecf6e6dbb0d90705be6b559203a7f45bb8a0 (image=docker.io/dcsunset/taskwarrior-webui:latest,>
Oct 26 01:19:24 localhost.localdomain systemd[835]: Started Podman container-287516d806e5dec732bb2152568304950343e98c75cd05f8ade36826a2d292e2.service.
Oct 26 01:19:24 localhost.localdomain podman[1636]: 2023-10-26 01:19:24.649773078 +0900 KST m=+2.658114401 container start af8cfa352332489ffaa29c82efd7ecf6e6dbb0d90705be6b559203a7f45bb8a0 (image=docker.io/dcsunset/taskwarrior-webui:latest>
Oct 26 01:19:24 localhost.localdomain podman[1636]: af8cfa352332489ffaa29c82efd7ecf6e6dbb0d90705be6b559203a7f45bb8a0
Oct 26 01:19:46 localhost.localdomain taskwarrior-webui[1801]:
Oct 26 01:19:46 localhost.localdomain taskwarrior-webui[1801]: > [email protected] start
Oct 26 01:19:46 localhost.localdomain taskwarrior-webui[1801]: > node ./dist/app.js
Oct 26 01:19:46 localhost.localdomain taskwarrior-webui[1801]:
Oct 26 01:19:50 localhost.localdomain taskwarrior-webui[1801]: Server listening on http://0.0.0.0:3000