How to fix Android studio turns off, freezes?

Hello,
I use Android Studio.
I have AMD Ryzen 5 series.
Linux manjaro.

fs.protected_fifos = 1
* Applying /usr/lib/sysctl.d/50-pid-max.conf ...
kernel.pid_max = 4194304
* Applying /usr/lib/sysctl.d/60-libvirtd.conf ...
fs.aio-max-nr = 1048576

What I did:

Add a file in /etc/sysctl.d containing

fs.inotify.max_user_watches = 1048576
then reload

sysctl -p --system
Then restart your IDE
swapon                                                           ✔ 
NAME      TYPE SIZE USED PRIO
/swapfile file   4G 3,7G   -2

I have 16GB RAM, should I increase it? Now with Android studio launched it’s almost fully used.

I set java version to 8 than like was before 11.

archlinux-java set jre8-openjdk-8.352.u08-2-x86_64     

I have installed earlyoom

● earlyoom.service - Early OOM Daemon
     Loaded: loaded (/usr/lib/systemd/system/earlyoom.service; enabled; preset: disabled)
     Active: active (running) since Mon 2023-01-23 08:50:40 CET; 2h 0min ago
       Docs: man:earlyoom(1)
             https://github.com/rfjakob/earlyoom
   Main PID: 476 (earlyoom)
      Tasks: 1 (limit: 10)
     Memory: 1.6M (max: 50.0M available: 48.3M)
        CPU: 838ms
     CGroup: /system.slice/earlyoom.service
             └─476 /usr/bin/earlyoom -r 3600 -n --avoid "(^|/)(init|systemd|Xorg|sshd)\$"

sty 23 10:38:51 hpenvy earlyoom[476]: low memory! at or below SIGTERM limits: mem 10.00%, swap 10.00%
sty 23 10:38:51 hpenvy earlyoom[476]: sending SIGTERM to process 10632 uid 1000 "java": badness 982, VmRSS 2972 MiB
sty 23 10:38:51 hpenvy earlyoom[476]: process exited after 0.6 seconds
sty 23 10:38:51 hpenvy earlyoom[11083]: Failed to open connection to "system" message bus: Did not receive a reply>
sty 23 10:43:37 hpenvy earlyoom[476]: mem avail:   619 of  6893 MiB ( 8.99%), swap free:    0 of 4095 MiB ( 0.01%)
sty 23 10:43:37 hpenvy earlyoom[476]: low memory! at or below SIGTERM limits: mem 10.00%, swap 10.00%
sty 23 10:43:37 hpenvy earlyoom[476]: sending SIGTERM to process 11103 uid 1000 "java": badness 963, VmRSS 2687 MiB
sty 23 10:43:38 hpenvy earlyoom[476]: process exited after 0.6 seconds
sty 23 10:43:38 hpenvy earlyoom[12220]: Failed to open connection to "system" message bus: Did not receive a reply>
sty 23 10:50:46 hpenvy earlyoom[476]: mem avail:  1335 of  6893 MiB (19.38%), swap free:  326 of 4095 MiB ( 7.96%)
~

this is empty, but in tutorial that was said to enter a file here? I just have changed global conf~ IMO.

    /etc/sysctl.d  ls                                                                                  ✔   
    /etc/sysctl.d                                                                                      ✔   


What else can I do how to prevent these crashes? How to check my logs?

Increase your swap to at least 10GB.

Yes if you can. RAM is better than swap.

Or you can try to use less memory, close some programs if you can.

1 Like

@dmt thank you so mcuh , aarhus for you as well.
I set it for 14GB, as far as I saw max was 8GB~ in usage. Should I decrease it a little bit?

To be honest I do not understand what exactly swapon do, but it works! Maybe you would like to write in own words how do you understand this tool?

1 Like

14GB is fine, you want some extra in case you use more than usual. You’re welcome. :slight_smile:

EDIT:

@chrisWW

Did you change the solution or someone else? Not sure how @linux-aarhus’s link is a solution, it doesn’t seem to mention anything that would solve this, maybe I missed it. :man_shrugging:

1 Like
  1. My RAM is 16GB, I think I can’t set swap for example 20GB as you mentioned, can I? If yes, why?. I still don’t understand what is swap space. I use swap space, which uses RAM so basically I let my RAM to give to swap his 14GB of RAM, which swap tool will use to clean and try to provide as much as it can from this 14GB instead of normally use 14+2 GB RAM(beacuse it doesn’t have that much, fast cleaning mechanism and in my case it crashes) does it correct?

  2. Could I have any pros of creating 2-3 swapon files of maximum 16GB(together) on the same ONE RAM? Or how to check if on this computer I have two seprated 2x 8GB? I don’t want to take cover off.

  3. If you want to alter it permanently then you need to change the vm.swappiness parameter in the /etc/sysctl.conf file.

    /etc/sysctl.d  cat /etc/sysctl.conf                                 ✔ 
cat: /etc/sysctl.conf: No such file or directory

I can’t access this file, why? Should I create it by myself?

Deprecation of /etc/sysctl.conf

2013-09-17 - Gaetan Bisson

From version 207 on, systemd will not apply the settings from /etc/sysctl.conf anymore: it will only apply those from /etc/sysctl.d/*. Since the settings of our /etc/sysctl.conf shipped by procps-ng have become kernel defaults anyway, we have decided to deprecate this file.

On my system in /etc/sysctl.d/
I have a file called 99-sysctl.conf with the following added:

# Decrease swap usage to a more reasonable level
vm.swappiness=10
1 Like

Swap doesn’t use RAM. It’s a way of extending RAM using storage devices such as HDDs and SSDs. It also allows more efficient use of RAM, and hibernation.

You have 16GiB RAM + 14GiB swap, so you have 30GiB of virtual memory. When you only had 20GiB of virtual memory you were running out.

Swap is slower than RAM, but better than crashing or having things you’re working on closed. HDDs are a bit too slow, SSDs are much better.

Multiple swap files/partitions are fine, but preferably on separate drives. If you’re going to put them all on the same drive then it’s probably better to make a bigger swap file instead. Having them on separate drives makes swap faster, see the Priority and Striping sections at the bottom of this link.

https://wiki.archlinux.org/title/Swap

I hope that helps, if you have any questions just ask. :slight_smile:

1 Like

Wow, sounds really amazing. Thank you for help. So definitely I will add some 6GB more, why not? :smiley: Super!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.