进程因内存不足而被终止 - 如何限制进程的内存?

进程因内存不足而被终止 - 如何限制进程的内存?

我在 Ubuntu 20.04 中安装了 Matlab 2020a。尝试运行代码时,Matlab 程序被终止,但它在另一个系统中运行正常。运行时检查资源显示 8gb RAM 和 10gb Swap 在被终止之前已耗尽。

尝试将 Java 堆内存更改为大约 1.5GB,以及从 Matlab 首选项中的工作区设置中取消选中最大数组限制选项。

dmseg输出有这些行

oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),cpuset=/,mems_allowed=0,global_oom,task_memcg=/user.slice/user-1000.slice/[email protected],task=MATLAB,pid=14659,uid=1000
[ 2166.872604] Out of memory: Killed process 14659 (MATLAB) total-vm:24372208kB, anon-rss:7121400kB, file-rss:0kB, shmem-rss:4kB, UID:1000 pgtables:35440kB oom_score_adj:0

syslog有这些线

kernel: [16207.494793] Out of memory: Killed process 50687 (MATLAB) total-vm:22123872kB, anon-rss:6511936kB, file-rss:0kB, shmem-rss:92kB, UID:1000 pgtables:31144kB oom_score_adj:0
/usr/lib/gdm3/gdm-x-session[1638]: (EE) client bug: timer event9 tap: scheduled expiry is in the past (-998ms), your system is too slow
kernel: [16208.142159] oom_reaper: reaped process 50687 (MATLAB), now anon-rss:0kB, file-rss:0kB, shmem-rss:108kB

有什么方法可以限制 使用的内存和交换空间matlab?我尝试过ulimit使用-m-v标志,但根本matlab打不开。

同一台机器上的 Windows 中不存在此问题,因此该问题似乎只出现在 Ubuntu 中的 MATLAB 中。有没有办法让它在 ubuntu 中工作?

答案1

ulimit是你的朋友。检查 -m 标志。我认为你在启动进程之前设置了它,它从那时起就适用(在当前 shell 中)。

来自帖子针对可能导致操作系统崩溃的贪婪应用程序的内存限制解决方案?

相关内容