I was using Ubuntu 19.10 and that was working perfectly, I decided to downgrade for some reasons to 18.04 LTS, It was also working fine in the starting but since a week before I am facing random lags while using Android Studio or IntelliJ Idea. Maybe I have installed any program which is causing this but I don't know. I have a very good system Corei9 12 cores with 16gb ram I also increased heap size but in vain. Currently, I am not in state to reinstall the OS. It lags randomly for 4,5 seconds while using Android Studio or IntelliJ Idea. The complete UI freezes during this, sound stops, cursor stops, etc... I don't have any graphics drivers issue as I am using built-in Intel HD graphics. Any method to diagnose this issue I don't know why is this happening.

Here is free -h

                  total        used        free      shared  buff/cache   available
    Mem:            15G        2.0G        7.2G        826M        6.4G         12G
    Swap:            0B          0B          0B

and sysctl vm.swappiness

vm.swappiness = 60

grep -i swap /etc/fstab

/swapfile                                 none            swap    sw              0       0
  • Edit your question and show me free -h and sysctl vm.swappiness. Start comments to me with @heynnema or I may miss them. – heynnema Apr 11 '20 at 21:30
  • Hey @heynnema thanks, I have edited my question. – Shahzad Akram Apr 11 '20 at 21:36
  • Show me grep -i swap /etc/fstab. How did you "I also increased heap size"? – heynnema Apr 11 '20 at 21:37
  • Now, finally, show me ls -al /swapfile – heynnema Apr 11 '20 at 21:40
  • @heynnema updated. – Shahzad Akram Apr 11 '20 at 21:40

User removed /swapfile.

The /swapfile is primarily used when RAM memory gets full, and the system moves active, but recently unused, pages of memory out to swap, and them pulls them back into memory when needed. This makes room in memory for other programs, or other active pages.

Warning: Improper use of the dd command can cause data loss.

sudo swapoff -a           # turn off swap
sudo rm -i /swapfile      # remove old /swapfile

sudo dd if=/dev/zero of=/swapfile bs=1M count=4096

sudo chmod 600 /swapfile  # set proper file protections
sudo mkswap /swapfile     # init /swapfile
sudo swapon /swapfile     # turn on swap
free -h                   # confirm 16G RAM and 4G swap
reboot                    # reboot and verify operation
  • Thanks, it solved my issue. But I noticed that issue even when I had plenty of free RAM. – Shahzad Akram Apr 11 '20 at 21:53
  • @ShahzadAkram didn't you say that it was originally a 1G /swapfile? Too small. You made it 4G now, as per my instructions, yes? – heynnema Apr 11 '20 at 21:55
  • Yes, but I was facing this after deleting that swap file. According to my concept of swap, it is a backup for RAM . But If the RAM is 50-60% available, does swap matter then? – Shahzad Akram Apr 11 '20 at 21:59
  • 1
    @ShahzadAkram It's not a backup for RAM. It works as I instruct in my answer. Yes, swap does matter. – heynnema Apr 11 '20 at 22:00
  • I got it. Thanks a lot. – Shahzad Akram Apr 11 '20 at 22:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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