3

I have bulky Fortran source code (WRF) to be compiled.

Every time I compile the code, the system gets stuck. To diagnose the problem, I saw memory performance in the system monitor of Ubuntu, and compilation eats the whole RAM. Then it also starts eating swap memory. My laptop has 4 GB RAM. I extended it to 8 GB RAM. I created a swap partition of 12 GB. But once my swap partition utilization reaches 4 GB. system hangs. Why is my whole swap partition is not being used (see below)?

2 Answers2

4

Why would you want swap usage to be higher?

Reading/writing to the swap is 1000 times slower than reading/writing to the RAM.

The system may not be hanging, it's just that it's so busy swapping stuff back and forth, it appears as though it hung.

@phihag said in the comments:

Most likely, when swap reaches 4GB this happens to be around the time that some part of the user interface gets swapped out. For instance, that could be the code to handle Ctrl+C, the keyboard layout handler, the code that displays output in the terminal, some data buffer of the terminal, some data buffer of the X server which paints pictures, etc. . Chances are if you wait a couple of hours either your swap is filled up or all of the data and code necessary for the Ctrl+C to be handled at the various layers has finally resulted in killing your Fortran process

I would suggest getting some more RAM. It will drastically speed up your compile. It's quite inexpensive nowadays, ~$60 for 16GB.

2

Using too much swap is bad for your system. More swap means more lag. Android Dev has already pointed out why you don't really want to use more swap. However there is a way to configure how often your system will use the swap partition. It is controlled by a setting called swappiness. You will find a detailed guide about modifying swappiness in this link.

I do not recommend you to increase swappiness. You can't even utilize a 12GB swap partition. The general rule is that swap should be half of your main memory. For you that is 2GB.

Amir
  • 73