Android Studio 很慢(如何加快速度)? [英] Android Studio is slow (how to speed up)?

查看:234
本文介绍了Android Studio 很慢(如何加快速度)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近从 Eclipse 升级到 Android Studio,但我不太喜欢这种体验.我在 Windows 7 64 位终极版16GB 内存和 Intel i7 4770 上比较它们,运行 NVidia Geforce 780 和最新的 NVidia驱动程序,如果重要,我正在运行最新的 JDK 和最新的 Android Studio.

I recently upgraded from Eclipse to Android Studio and I'm not really liking the experience. I'm comparing them both on a Windows 7 64 bit ultimate with 16GB of ram and Intel i7 4770 running NVidia Geforce 780 with the latest NVidia drivers if it matters and I'm running the latest JDK and the latest Android Studio.

Android Studio 在构建我可以忍受的项目时非常缓慢,但它也非常占用资源,有时会降低 PC 的速度.

The Android Studio is very slow in building the project which I can live with but it's also extremely resource intensive and sometimes slows down the PC to a crawl.

每当我在 AS 中构建或运行任何东西时,我的电脑似乎变得非常缓慢.如果我点击Gradle build running"微调器,它也会导致屏幕闪烁,偶尔会消隐我的第二台显示器,我觉得这很奇怪.RAM 使用量也高达 ~3GB,我觉得这对于什么都不做是多余的(这是在几次构建后空闲时).

Whenever I'm building or running anything in AS, my PC seems to become extremely sluggish. It also causes flickering of screen and occasionally blanking my second monitor if I click on "Gradle build running" spinner which I find very odd. The RAM usage also shoots up to ~3GB which I find excessive for doing nothing (this is when it's idle after a few builds).

此外,AS 底部的面板一直在跳来跳去,这是一种糟糕的用户体验(从 Android 移动到 Messages 再到 Version Control代码> 或其他任何根据正在发生的事情临时进行的操作,这非常非常烦人).

In addition, the panels at the bottom of AS keep jumping around which is a horrible user experience (moves from Android to Messages to Version Control or anything else on an ad-hoc basis depending on what's happening which is very, very annoying).

我想知道的基本上是:

1) 如何让 Android Studio 运行得更好?我可能做错了什么或错过了一些我不知道的更新,我相信其他人也注意到了这些行为并找到了一些解决方案.

1) How do I make Android Studio run better? I may be doing something wrong or missing some updates that I'm not aware of and I'm sure others have also noticed these behaviors and have found some solutions to it.

2) 我如何固定"底部面板,使它们不会四处跳跃,而是让我(用户)在需要时导航到它们,而不是自动切换它们?

2) How do I "pin" the bottom panels so that they don't jump around and instead, let me, the user, navigate to them when I wish to instead of automatically switching them?

非常感谢,如果这不是这些问题的正确位置,我再次道歉.

Many thanks and my apologies again if it's not the correct place for these questions.

编辑 1更多评论:

  • 我目前使用的是最新的 stable 版本.构建是 Android Studio 1.2.2 Build # AI-141.1980579,构建于 2015 年 6 月 3 日
  • 该行为在使用 Java 7 或 8 时发生.它似乎与 Java 版本无关.
  • 我没有使用演示模式.只是香草视图.
  • 对构建配置进行更改(感谢 @Blackbelt 和他的回答)似乎对构建有所帮助,但其他与缓慢和一般用户体验有关的问题仍然存在.

推荐答案

总结

1) 在 AndroidStudio 的 settings >compile 启用名为 Compile Independent modules in parallel 的复选框.

1) in AndroidStudio's settings > compile enable checkbox named Compile independent modules in parallel.

2) 在 Help> 下;编辑自定义 VM 选项 我有:

-Xms1024m 
-Xmx4096m # <------ increase this to most of your RAM 
-XX:MaxPermSize=1024m 
-XX:ReservedCodeCacheSize=440m 
-XX:+UseCompressedOops 
-XX:-HeapDumpOnOutOfMemoryError 
-Dfile.encoding=UTF-8

附言- 有些人说注意,不是 VM 选项,最好通过将这些行组合到 gradle.properties 中的一行单个命令来覆盖组合,如下所示:

P.S. - Some people say Note, instead of VM options, it's better to combine can be overriden by combining those lines into one line single command in gradle.properties, like this :

org.gradle.jvmargs=-Xms1024m -Xmx4096m ......

org.gradle.jvmargs=-Xms1024m -Xmx4096m ......

3) 我有一个带有 4GB 内存的旧双核,运行 ubuntu.Qs 命令行选项我只有 --offline (它指定构建应该在不访问网络资源的情况下运行).我还启用了其余的复选框,现在它运行正常:

3) I have an old dual core with 4GB ram, running ubuntu. Qs command line option I have only --offline (which specifies that the build should operate without accessing network resources). I also enabled the remaining checkboxes and now it's running ok:

  • 自动制作项目

  • Make project automatically

使用进程内构建按需配置

Use in-process building Configure on demand

检查AndroidStudio的设置,在编译下勾选Compile Independent modules in parallel已启用.

Check the AndroidStudio's settings, under compile that the checkbox Compile independent modules in parallel is enabled.

在 Vmoptions 下我有

Under Vmoptions I have

-Xmx2048m -XX:MaxPermSize=1024

我有一个带有 4GB 内存的旧双核,运行 ubuntu.Qs 命令行选项我只有 --offline ,它指定构建应该在不访问网络资源的情况下运行.我还启用了其余的复选框:

I have an old dual core with 4GB ram, running ubuntu. Qs commandline option I have only --offline , which specifies that the build should operate without accessing network resources. I enabled also the remaining checkboxes:

  1. 自动制作项目
  2. 使用进程内构建
  3. 按需配置

  1. Make project automatically
  2. Use in-process building
  3. Configure on demand

运行正常

编辑

可以通过位于(只需将 X.X 替换为版本)的 studio.vmoptions 提供其他选项:

It is possible to provide additional options through studio.vmoptions located at (just replace X.X with version):

  • Windows:转到 %USERPROFILE%\.AndroidStudioX.X\studio.exe.vmoptions(或 studio64.exe.vmoptions代码>)

  • Windows: go to %USERPROFILE%\.AndroidStudioX.X\studio.exe.vmoptions (or studio64.exe.vmoptions)

Mac:~/Library/Preferences/.AndroidStudioX.X/studio.vmoptions

Linux:~/.AndroidStudioX.X/studio.vmoptions(和/或 studio64.vmoptions)

增加 -Xmx 的值应该会有很大帮助.例如

Increasing the value of -Xmx should help a lot. E.g

-Xms1024m
-Xmx4096m
-XX:MaxPermSize=1024m
-XX:ReservedCodeCacheSize=256m
-XX:+UseCompressedOops

将分配 4G 作为最大堆,初始值为 1G

will assign 4G as max heap, with initial value of 1G

编辑:

在 Windows 上,默认值存储在 C:\Program Files\Android\Android Studio\bin\*.vmoptions 中.IDE 允许您通过 Help->Edit Custom VM options 调整这些值(感谢 @Code-Read 指出).

On windows the defaults are stored into C:\Program Files\Android\Android Studio\bin\*.vmoptions. The IDE allows you to tweak those values through Help->Edit Custom VM options (thanks to @Code-Read for pointing it out).

编辑 2:

Android studio 3.5 可以更轻松地更改这些值.只需前往:

Android studio 3.5 makes easier to change same of those values. Just go to:

Preferences > Appearance & Behavior > System Settings > Memory Settings

这篇关于Android Studio 很慢(如何加快速度)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆