Quick Linux Tip #115:
Question: A buggy script is eating all my RAM. How do I cap its memory usage?
Try: ulimit -v 524288
Info: Restricts virtual memory for the current shell session and its child processes.
Examples:
- $
ulimit -a# Display all current resource limits for the session - $
ulimit -t 60# Set a maximum CPU time limit in seconds - $
ulimit -n 65536# Limit the maximum number of open file descriptors
Note: Use /etc/security/limits.conf for persistent per-user limits, or systemd service settings (MemoryMax) for production services. ulimit can only restrict limits downwards.
Leave a Reply