0
i am trying to limit the memory usage of a process using ulimit
ulimit -Sv 100000
ulimit -St 10
fakechroot ./compiledfile
i am running the command in the same terminal (i am using ubuntu 16.04) and the source code of compiled file is
#include<stdio.h>
int main()
{
while(1)
{
malloc(110000000);
pf("allocated : %d\n",i);
}
return 0;
}
the process should get terminated because of memory limit..but it is running till the timelimit end.I don't understand why. I am novice,pardon me if the question is silly..any help or suggestion is appreciated..thanks
Not sure, but does
fakechroot
create a new process?ulimit
only affects the current process. You could try running a script withulimit
and your./compiledfile
insidefakechroot
– Joe P – 2017-06-11T17:15:21.083@joe P i have tried without fakechroot ( ./compiledfile ) bt no change – mursalin – 2017-06-11T17:21:55.513
1You should check the return value of
malloc
. It will returnNULL
when allocation fails due to memory limit or other reason. – x22 – 2017-06-13T12:09:41.647