Erlang:如何限制分配给进程的内存 [英] Erlang: How to limit the memory assigned to a process

查看:353
本文介绍了Erlang:如何限制分配给进程的内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要问的是是否有可能限制分配给特定进程的内存(堆或堆栈),以使该进程不能超过它. 也许像"process_flag(min_heap_size,MinHeapSize)"之类的东西,但是最大的堆.

What I'm asking is if it's possible to limit memory (heap or stack) assigned to a specific process, so that this process can't exceed it. Maybe something like "process_flag(min_heap_size, MinHeapSize)", but for the maximum heap.

推荐答案

您可以将某种进程跟踪gen_server放在一起,该服务器定期检查分配的进程的内存占用量,并在超过一定数量时将其杀死.

You could put together some kind of process tracking gen_server that periodically checks assigned processes for memory footprint and kills them if it exceeds a certain amount.

使用process_info(Pid, memory).exit(Pid, Reason)调用的组合,这应该很容易管理.

Using a combination of process_info(Pid, memory). and exit(Pid, Reason) calls, this should be quite manageable.

这篇关于Erlang:如何限制分配给进程的内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆