3

Whenever I type any single letter, Android Studio tries to seek suggestion of methods and classes, and this freezes program. Even though I wait, it doesn't show any suggestions at the end whether I try to type proper method/class name or not.

I tried to check CPU usage first because whenever I try to type letters, CPU usage suddenly jumps up to about 90% from 0~10%. I took screenshot of Activity Monitor, and total CPU usage keeps exceeding 100 whenever I try to type single letter

enter image description here

Plugin Kotlin takes ridiculously high CPU usage only for trying to seek suggestions. There are about 300 classes including both Java and Kotlin classes.

enter image description here

I set IDE max heap size as 8GB because I have 16GB RAM

enter image description here

I'm using Android Studio 4.2 Beta 2 version

enter image description here

Invalidating/Restarting caches didn't work. Removing .idea folder in Android project folder also didn't work.

Is there any reason for this problem? and can I solve this problem?

Mandarin Smell
  • 391
  • 2
  • 17

1 Answers1

1

It turned out that some class was causing problem, this class is java with generics. T in generic requires to extend Enum and implement my other class, this seems to cause Android Studio freeze. I'm trying to find a way to reproduce, but solved it by creating static java method which handles my codes. Only Kotlin is causing freezings.

Mandarin Smell
  • 391
  • 2
  • 17
  • I faced a similar issue on Android Studio 4.2 (snap) on Ubuntu. I can reproduce it only inside one (Kotlin) class with generics, when I add extra curly brace to "if" statement or remove one. If I do so, AS eat up all available memory and just freezes forever. I've tried to set Xmx to 10GB, but no luck, although usually it worked fine with 2GB! I absolutely don't understand what to do and how to avoid it. This is the first time I've encountered this in several years of work. – Victor Cold Jun 10 '21 at 16:41