在内核使用OOM(Out of Memory)终止应用程序之前执行脚本或进程。

huangapple go评论97阅读模式
英文:

Execute script or process right before kernel kills app with OOM

问题

在 OOM(Out of Memory)发生之前运行脚本的方法有吗?

我的 Go 进程会逐渐积累内存,最终由于主机内存不足而被内核杀死。

该进程通过一个 HTTP 套接字暴露 pprof 指标,我想要运行的脚本将会使用 curl 命令连接到该套接字,并保存 pprof 的内存信息。

这样我就有了一个基础来调试为什么进程会耗尽内存的问题,正如这个 GitHub 帖子中所推荐的那样。

更多信息:

错误信息:

Out of memory: Killed process 9421 (process_name) total-vm:10185280kB, anon-rss:6358304kB, file-rss:0kB, shmem-rss:0kB, UID:994 pgtables:12884kB oom_score_adj:0

我知道杀死进程的信号是由内核发送的,所以我的进程无法订阅该信号,但是否有其他信号我应该关注?或者最好的做法是定期轮询本地的 pprof URL 吗?

谢谢!

英文:

Is there a way to run a script right before a process is killed for OOM?

My go process is slowly accumulating memory and eventually the kernel kills it because the host is going out of memory.

The process exposes pprof metrics over an http socket, and the script I want to run would curl to that socket and save the pprof memory information.

That way I have a base for debugging why the process goes out of memory, as recommended in this GitHub post.

More info:

The error:

Out of memory: Killed process 9421 (process_name) total-vm:10185280kB, anon-rss:6358304kB, file-rss:0kB, shmem-rss:0kB, UID:994 pgtables:12884kB oom_score_adj:0

I know the kill signal is kernel-only, so my process cannot subscribe to that, but is there another signal I should be looking into? Or might the best course of action be to poll the localhost pprof URL at regular time intervals?

Thanks!

答案1

得分: 1

在OOM(内存耗尽)之前运行脚本的方法吗?

没有。

英文:

> Is there a way to run a script right before a process is killed for OOM?

No.

huangapple
  • 本文由 发表于 2022年2月10日 03:15:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/71055414.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定