So, I'm sure that many have already asked about how to limit a process memory usage. As far as I could find, there is no real solution for this problem.
However, I'm running some few tests now in MATLAB and I need whatever I can have, since with no control at all MATLAB just sucks all the resources and crash my machine.
I've created a simple script which does
Code: Select all
#!/bin/bash
ulimit -Sv $MEM_LIMIT
cpulimit -P /opt/matlab$VERSION/bin/glnxa64/MATLAB -l $CPU_LIMIT &
CPULIM_PID=$!
echo "cpulimit pid is $CPULIM_PID"
echo "Starting Matlab..."
/opt/matlab$VERSION/bin/matlab -desktop -nosplash
echo "Matlab has finished successfully"
echo "Cleaning cpulimit"
kill -9 $CPULIM_PID
I don't like the idea of running this as root. Any suggestions?



