Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm currently coding on my laptop: 4 gb of rams, never using more than 2.5-3gb but at times, I'll mess up my programs, run them with memory leaks and they'll make the computer freeze when trying to write in the swap file (something related to low value of swapiness). It put me close to losing important data a few times and so I'd like to have my computer working another way: no swap file, as I said I've never needed more than 3gb of ram when using it, and making the OS crash a program that would try to use more ram than available (it will always an ill coded program of my own). How can I get my setup this way?

Thank you in advance.

share|improve this question
add comment

2 Answers

If you know which program is causing the problem (as your question suggests), then you should login on another terminal by pressing Ctrl+Alt+F2, and then doing a killall <processname>. Pressing Ctrl+Alt+F7 or Ctrl+Alt+F8 will take you back to GUI.

If you must deactivate swap, then you need to edit the /etc/fstab file. sudo gedit /etc/fstab

There will be one line which would have the word "swap" in it. Put a # in beginning of the line. Save the file, and exit. Reboot the system, and your swap should be gone. This can be verified through system monitor.

share|improve this answer
    
Hi, I commented the line in fstab. Thank you for the tips, though I don't think that I can kill the program, the computer freezes completely, I can't even open a terminal or move the pointer; everytime I end up having to hard reboot it. –  Learning is a mess Feb 5 at 15:35
add comment

try kill -STOP pid && swapoff /path/to/yourswapdev

then after this, the program you are running may be bad coded.

You can try to keep linux stable even if the task is causing problems, and you still want to use it

try renice -n 20 -p pid

To continue tha task use kill -CONT pid

Notice: If the task starts on bootup you will need to replace the regular exec for a nice command in the startup script

PDv2: Avoid swap from loading at startup commenting it's line in /etc/fstab

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.