3

I'm a developer working a lot with Android Studio. When it compiles the Java classes it spins up 4+ threads of CPU intensive work. Often I play music in the background when that goes on. Here's what happens:

  • The music skips or completely stops at the most intensive section of the compilation
  • The mouse point jitters or stops responding altogether

Most often things normalize after compilation is done, but other times the computer freezes totally and I have to hard reset it. How come? Is not Linux/Ubuntu/Unity designed to prioritize the UI thread? How does it allow Java to take 100% of the CPU resources? Is there any way I can throttle this?

Disclaimer: I don't know much about OS code.

1

1 Answer 1

5

The linux kernel is really good at managing the CPU, so I think your problem is IO related. It is totally normal that the CPU is used 100% when you're compiling, and this is what you've paid for.

However, I agree with you, the UI should not be so badly affected.

About your unresponsiveness of your system

I think you should try ionice to lower the IO priority of android studio.

Memory

It's also possible that your system is low on RAM, and start using swap. top can be used to see the swap usage. This can be fixed either by reducing RAM usage, by adding RAM or eventually tuning the swappiness of your system.

Unfortunately, I'm not a user of Android Studio, and I can't help with it's configuration.

About the complete freeze

This should really not happen, this is a bug and you should fill a bug on the ubuntu bugtracker.

But before filling a bug, I think you should update your system, including installing the latest HWE kernel and Xorg (see here).

2
  • More research leads me to believe it's memory-related. Process kswapd0 hogs CPU when I notice jittering. No easy solution for that I guess (except download more RAM). I'm accepting your answer as it adresses CPU congestion.
    – Nilzor
    Nov 14, 2017 at 9:46
  • Added a small paragraph about memory usage
    – pim
    Nov 14, 2017 at 9:57

Not the answer you're looking for? Browse other questions tagged .