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

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

问题描述

我最近从Eclipse升级到Android Studio,但我并不喜欢这种体验.我正在将它们都在具有以下操作系统的 Windows 7 64位旗舰版 16GB ram和运行最新NVidia Geforce 780和最新NVidia的 Intel i7 4770 上进行比较.驱动程序是否重要,我正在运行最新的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中构建或运行任何软件时,我的PC似乎都变得非常缓慢.如果我单击"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底部的面板会不断跳来跳去,这是一种可怕的用户体验(根据发生的情况,从AndroidMessagesVersion 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, Build on June 3, 2015
  • 使用Java 7或8时会发生这种情况.这似乎与Java版本无关.
  • 我没有使用演示模式.只是香草的景色.
  • 对构建配置进行更改(由于@Blackbelt和他的回答)似乎对构建有所帮助,但是仍然存在缓慢和一般用户体验的其他问题.
  • I'm using the latest stable build as of today. The build is Android Studio 1.2.2 Build # AI-141.1980579, Build on June 3, 2015
  • The behavior happens when using either Java 7 or 8. It doesn't appear to be related to the version of Java.
  • I am not using Presentation Mode. Just the vanilla view.
  • Doing the changes to the build configuration (thanks to @Blackbelt and his answer) appears to have helped with the build but the other problems with sluggishness and general user experience remain.

推荐答案

总结

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> Edit Custom VM Options下,我有:

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

P.S. -有人说请注意,最好不要合并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 ram的旧双核,正在运行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

在编译时选中复选框Compile independent modules in parallel的情况下,检查AndroidStudio的设置.

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 ram的旧双核,正在运行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

它运行正常

修改

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

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)

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天全站免登陆