如何在Linux中为进程分配更多的内存 [英] how to allocate more memory to a process in linux

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

问题描述

我正在64位Fedora 16上使用CAD程序.有一次,程序突然崩溃并完全退出.我最初的猜测是该程序没有足够的内存来执行该操作,然后退出.为了对其进行测试,我想为该特定程序分配更多的内存,这样做是可以的,如果其他程序没有足够的内存.我怎样才能做到这一点?我怎样才能(希望通过终端)告诉系统将增加的内存分配给特定进程?

I am using a CAD program on 64 bit Fedora 16. At one point the program suddenly crashes and completely exits. My initial guess is that there is not enough memory available for that program to perform that operation and it quits. To test it, I want to allocate more memory to that particular program and in doing so I am ok if other programs do not have enough memory. How can I do this? How can I tell (hopefully through terminal) the system to allocate increased memory to a particular process?

推荐答案

这不是在Unix/Linux上进行内存管理的方式.您无需为进程分配内存,它们只是在需要时请求更多虚拟内存.

That's not how memory management works on Unix/Linux. You don't allocate memory to processes, they just request more virtual memory as they need it.

也许您在说的是进程的虚拟内存限制.您可以使用Shell的ulimit命令来设置各种进程限制;例如:使用-d选项设置进程的数据段(即堆)的最大大小,并使用-s设置堆栈.但是,非root用户只能降低其限制,而不能提高它们.此选项适用于该shell进程以及从中运行的所有程序;我不确定您如何通过GUI窗口管理器对应用程序执行此操作(也许将命令放在.xinitrc中).

Maybe what you're talking about is the process's virtual memory limit. You can use the shell's ulimit command to set various process limits; use the -d option to set the maximum size of the process's data segment (i.e. the heap), and -s for the stack. However, non-root users can only reduce their limits, they can't increase them. This option applies to that shell process and any programs run from it; I'm not sure how you'd do this for applications from the GUI window manager (maybe put the command in your .xinitrc).

系统管理员可以在/etc/security/limits.conf中配置每个用户和每个组的默认限制.

The system administrator can configure per-user and per-group default limits in /etc/security/limits.conf.

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

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