0

I have a 4GB RAM laptop with 500GB hard-disc space and I'm using Ubuntu 18.04 LTS. So, I need to use the android studio a lot and recommended RAM for that is 8GB. My computer crashes a lot lately so really either should buy an 8GB Ram to do the swap partition. I would love to find a solution with no costs!

So my question is this: Should I swap space to double my RAM? Would that be harmful to my computer? Please, guys, be nice!

2
  • Hello and welcome to AskUbuntu! You might get away with "lots" of swap space (2x installed RAM was the norm ages ago), but your laptop would probably get unusable even if not crashing. You should definitively get a RAM upgrade. That said, your question is probably offtopic here and will probably be closed. Sep 14, 2018 at 10:07
  • 4
    Possible duplicate of I have 16GB RAM. Do I need 32GB swap? Refer to the table in this answer: askubuntu.com/questions/49109/…
    – karel
    Sep 14, 2018 at 10:17

2 Answers 2

1

It depends whether you are compiling larger projects or even Android system itself. When you are using less RAM (4GB) then the computer will use more swap space. I upgraded two computers from 4GB to 8GB and in both cases it was a performance boost. The computers are not using so much swap and are faster regarding gaming or compiling.

My recommendation is to upgrade the RAM, especially if you are going to work on more complex projects.

Regarding the crashes - check your HW components for eventual failure (Memtest or similar).

1

You for sure could and should (see reasons below) have swap memory. However, do not count on swap memory to solve shortages of RAM for your software.

Although you will be able to load and run android studio, you will quickly notice that in practice, it will not be workable. Swap is extremely slow, and you quickly will notice very slow response of your computer, so called "disk trashing" and occasional freezing for several minutes.

Swap would be faster if you would locate it on a much faster SSD drive. Even then, it would be significantly slower than using real RAM. The intensive writing would quickly wear out your SSD drive. Each area of an SSD drive supports a limited number of writes.

There are some reasons why swap memory nevertheless is useful. See here for one general reason. Other reasons to maintain swap are:

  1. To hibernate a computer. To be able to hibernate a system (turn fully off, but maintain the current session in SWAP so memory can be restored on next boot), a swap with a size of at least the memory of the system is needed. Caveat: it is quite common for hibernation not to work correctly with linux.
  2. To improve performance on low memory systems: On lower memory systems, some less used memory may be swapped to disk, freeing memory for other activities you are doing. Caveat: if memory becomes too limiting, you will revert to the unworkeable performance of the system I referred to above.

Bottom line is that you should not rely on the swap memory for daily use of software requiring a lot of memory. The only good solution here will be to invest in RAM.

Note that, if you did a fresh install of Ubuntu, you will not have a swap partition but a swap file. The installer should have that configured in an optimal way with respect to normal desktop usage considering the amount of RAM you have. I would leave the settings as is.

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