Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio shows the warning inotify limit is too low

Every time on start Android studio displays a warning.

The current inotify(7) watch limit is too low.

I don't understand what it is all about. Should I be worried about it ? If anyone can clear about the concept of this watch limit I would be very thankful .

enter image description here

like image 398
lakshay Avatar asked Nov 27 '15 14:11

lakshay


People also ask

What is Inotify limit?

inotify requires kernel resources (memory and processor) for each file it tracks. As a result, the Linux kernel limits the number of file watchers that each user can register. The default settings vary according to the host system distribution; on Ubuntu 20.04 LTS, the default limit is 8,192 watches per instance.

What is FS Inotify Max_user_watches?

inotify. max_user_watches define user limits on the number of inotify resources and inotify file watches. If these limits are reached, you may experience processes failing with error messages related to the limits, for example: ENOSPC: System limit for number of file watchers reached...


2 Answers

According to the IntelliJ documentation,

For an intelligent IDE it is essential to be in the know about any external changes in files it working with - e.g. changes made by VCS, or build tools, or code generators etc. For that reason, IntelliJ platform spins background process to monitor such changes.

Inotify requires a "watch handle" to be set for each directory in the project. Unfortunately, the default limit of watch handles may not be enough for reasonably sized projects, and reaching the limit will force IntelliJ platform to fall back to recursive scans of directory trees.

Therefore, you need to add

fs.inotify.max_user_watches = 524288 

in "/etc/sysctl.conf"

and then run the following command for it to take effect

sudo sysctl -p 

Let me know if this helps !

like image 79
Suhas Avatar answered Sep 29 '22 05:09

Suhas


Here's the clean and easy copy-and-paste fix:

  1. Simply copy-and-paste this multi-line command into your shell. It will create the file /etc/sysctl.d/android-studio.conf which will apply the necessary inotify limits upon every system startup:

     cat << EOF | sudo tee /etc/sysctl.d/android-studio.conf  # Increase inotify limit, required by Android Studio, https://confluence.jetbrains.com/display/IDEADEV/Inotify+Watches+Limit  fs.inotify.max_user_watches = 524288  EOF 
  2. Reload your new sysclt configuration file (and all the others):

     sudo sysctl -p --system 
  3. Restart Android Studio.

Here's the IntelliJ documentation for completeness: https://confluence.jetbrains.com/display/IDEADEV/Inotify+Watches+Limit

like image 24
Stephan Henningsen Avatar answered Sep 29 '22 07:09

Stephan Henningsen