Development Tip

항상 100 % 이상의 CPU를 사용하는 Android 스튜디오-실행중인 백그라운드 프로세스가없는 것 같습니다.

yourdevel 2020. 10. 14. 21:20
반응형

항상 100 % 이상의 CPU를 사용하는 Android 스튜디오-실행중인 백그라운드 프로세스가없는 것 같습니다.


IDE가 실행중인 백그라운드 프로세스 (인덱싱 등)가없는 것처럼 보이는 경우에도 Android Studio (실행 중일 때)가 항상 100 % 이상의 CPU를 사용하는 것으로 나타났습니다. 나는 이것이 내 상자에 특정한 것이라고 생각할 수 있지만 일부 동료 개발자 도이 문제를 겪고 있습니다.

종종 CPU 사용량이 100 초 또는 200 초 중반에 있습니다 (아래 스크린 샷 참조). 누구도 이것을 만났습니까? 그렇다면 IDE 내에 이러한 집중적 인 시스템 리소스 사용을 수정하기위한 전략이나 옵션이 있습니까?

여기에 이미지 설명 입력

여기에 이미지 설명 입력


파일 메뉴에서 다음 옵션을 시도 할 수 있습니다.

  1. 파일 메뉴-> 캐시 무효화 / 다시 시작 ...-> 무효화 및 다시 시작
  2. 파일-> 절전 모드 를 클릭하여 절전 모드활성화합니다.

절전 모드는 코드 통찰력 및 백그라운드 작업 만 비활성화합니다.


파일> 캐시 무효화 / 다시 시작으로 이동하는 것을 고려할 수 있습니다. 캐시가 백그라운드에서 펑키 한 것을 시작하고있을 수 있습니다.

여기에 이미지 설명 입력


Buzzrick (이 페이지에서 대답, 아마도 내 대답 위에 답변) 덕분에 그는 VCS에 대해 언급했습니다. VCS의 모든 백그라운드 작업을 끄는 것은 높은 CPU 사용량에 큰 영향을 미치는 것처럼 보였습니다. 150 % 였지만 지금은 20 % 정도입니다.

OS X를 사용 중입니다.

이동 : 환경 설정> 버전 관리> 배경. 이제 '백그라운드 작업'에 6 가지 옵션이 나열됩니다. 처음 세 가지 옵션을 비활성화했습니다 .

백그라운드에서 VCS 업데이트 수행, 백그라운드에서 VCS 커밋 수행, 백그라운드에서 VCS 체크 아웃 수행


I encountered a constant high cpu usage with no apparent reason. Invalidating cache did not work nor did the power save mode.

In my case there was a something wrong in the '.git' directory which was causing android studio to fail in an endless loop. Checking out the repo again fixed the problem.

My advice is to check the android studio logs for any hints to what is causing it to falter. You could also start it from terminal and check the Stdout/Stderr output.


I had exact same problem on Linux. Solved by increasing the memory size.

Started by looking at the top -p <android studio pid> -H which shows which threads are using most of CPU, to me there are three threads: 94232,94233,94234. Then I do a jstack <pid> to get the stack dump of android studio, and look for 0x17018 (=94232), it turns out to be "Gang worker#0 (Parallel CMD Threads)". All three of them. apparently JVM is too busy doing GC all the time.

Also opened jconsole against my android studio process and it shows GC time "20 minutes"!!! (at the bottom of memory tab)

Fix is to change the studio.vmoptions (or studio64.vmoptions in my case), to increase the -Xmx value from default 750m to 1500m. It is sufficient for me. if you have too much memory, set to 2g or 4g or 16g..


I switched on power save in Android Studio 1.0 it helped but this meant I opted out on so many features that Android Studio has to offer. Thus I sought to find a better solution, I happened to always have a dialog box pop up and ask me to increase my VM size. Apparently once I increased this, I am able to switch off power save and have my Android Studio work perfectly.

This is how to do so: On Mac OS go to /Applications/Android\ Studio.app/Contents/bin/studio.vmoptions (To open contents right click on Android Studio app > View contents) You will find the following variables

-Xms128m
-Xmx4096m
-XX:MaxPermSize=1024m
-XX:ReservedCodeCacheSize=200m
-XX:+UseCompressedOops

On Windows go to Environment Variables and find a System Variable called _JAVA_OPTIONS

Increase these figures accordingly.

  • Xmx specifies the maximum memory allocation pool for a Java Virtual Machine (JVM).
  • Xms specifies the initial memory allocation pool.

i.e Your JVM will be started with Xms amount of memory and will be able to use a maximum of Xmx amount of memory.


Interestingly, for me this seemed to be something to do with the version control integration.

I fixed this by re-loading my android studio project and when it asked about wiring up my CVS links (I don't recall the exact wording), I just said "Ignore". After that it ran smoothly without pulling CPU


I tried the following procedure and Android Studio on my Surface Pro 3 sped up by an insane amount:

  1. Reduce the amount and memory of the Android Virtual Devices you have.
  2. Invalidate Caches/Restart
  3. Go to Power Save Mode
  4. Close all unnecessary files that are opened.
  5. Reduce your VM Heap Size to around 256.

On Windows I reduced the studio64.exe process priority and set the process' affinity to half of the cores. Open Task Manager, click on Processes tab, right click on process studio64.exe and you'll see it in the menu.


On Android Studio 2.3, this happens when the "Android Monitor" window is open (the window shows Logcat messages from devices and emulators), and then you press Ctrl+F (Cmd+F on the Mac) to reveal the 'Find' search bar inside this window.

It can also happen when you connect a Samsung phone to your computer via USB, which has Developer Mode enabled, because Samsung phones usually send out large amounts of debug text to Logcat every second, even if the Logcat window is closed.

So the solutions to prevent the 100% CPU usage are:

Turn off the Find search bar, or hide the window completely.

or

Disconnect a Samsung phone which is sending out lots of debug messages.

or

Upgrade to Android Studio 3, where this bug doesn't happen.


I've left this question open for awhile as coworkers and posters here have found value in various solutions over time. For myself, simply updating Android Studio solved the issue (after a number of months where none of the solutions herein worked for me).


In my case I have white-listed Android-Studio's folder in "Eset Smart Security" and the problem solved!

hope this helps!

Edit:

Disabling HIPS in Eset settings was also helpful in my situation!

참고URL : https://stackoverflow.com/questions/19986498/android-studio-using-100-cpu-at-all-times-no-background-processes-appear-to

반응형