Hi All,
What's the default maximum amount of memory that a process can use on a linux system?
Does it depend on the user?
Where can it be changed?
What happens if this maximum is exceeded? I assume malloc will fail?
Thanks for your help,
rotis23
This is a discussion on max memory within the Linux Programming forums, part of the Platform Specific Boards category; Hi All, What's the default maximum amount of memory that a process can use on a linux system? Does it ...
Hi All,
What's the default maximum amount of memory that a process can use on a linux system?
Does it depend on the user?
Where can it be changed?
What happens if this maximum is exceeded? I assume malloc will fail?
Thanks for your help,
rotis23
-- depends your settings. one of them allows use of approx 96% and 4% is left for os / what it needs at runtime ( or something like that ). this is quite safe, linux wont never crash while allocating memory. kernel kills process if it tries allocate more than there's available. (available physical memory + available swap).
Last edited by tjohnsson; 05-17-2004 at 06:56 AM.
I have crashed linux allocating too much memory before, albeit when I was root with a bad kernel module I wrote when a loop never exited![]()
Help populate a c/c++ help irc channel
server: irc://irc.efnet.net
channel: #c
Nice one chrismiceli!!!!!!!!!!
So the kernel will `kill -9' (SIGKILL) the process rather than return an error to a memory allocation function (e.g. malloc)?
If you are using malloc then it should return NULL and as long as you do your error checking correctly you'll be ok.
What can cause the fault (which I've done) is when you have too deep of recursion and you fill the stack up, try to get more, and then the kernal smacks you for trying to use memory it hasn't said you can use.
Edit: Oh the max amount of memory used on a per user base and/or a per group base can be done. Same with CPU %. I just don't know where![]()
Looks like it's /etc/security/limits.conf - on a redhat system anyway.
I got message 'killed' to the terminal and 'dmesg' shows more information why kernel has done so.Originally Posted by rotis23
and was checking malloc against NULL but it did't change kernel behaviour...
Last edited by tjohnsson; 05-17-2004 at 11:13 PM.
it's safety feature when kernel kills running process if there's no more available memoryOriginally Posted by Thantos
echo 1 to /proc/sys/...somedir.../...somedir.../overcommit_memory to get malloc return NULL and error handling is leaved to running process.