2

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.

1
  • "something related to low value of swapiness" - this may be a silly question, but if this is caused by low swappiness, why not just set swappiness back to the default? Sep 26, 2014 at 5:18

2 Answers 2

2

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.

1
  • 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. Feb 5, 2014 at 15:35
0

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .