解决android studio死机卡死卡缓慢问题的实践

         之前使用eclipse,后来google公司自己推出了一个安卓的开发工具android studio,并且渐渐的停止对eclipse的兼容和支持,所以我也从eclipse跳到使用androidstudio了,但是android studio使用起来时不时的出现死掉卡机卡顿,让我很郁闷,只能干巴巴等着他恢复过来,为了缓解甚至解决这个问题,我采用了两种方法:

方法1:升级自己的电脑配置。我家里的电脑,我自己掏腰包把内存加到8G,并加上了一个固态硬盘,把系统分区(就是C盘)放在固态硬盘上,原来的那个机械硬盘就当从盘存储一些东西,把32位的系统换成64位,结果一试,哇,不在卡了!家里的电脑是咱们的自己,想怎么搞都行,但是公司的电脑怎么办?所以有了方法2.

方法2:设置 android studio的某些参数。方法1的办法当然好,但有的时候,尤其是在公司,公司的电脑,除了使用上面的办法外,还可以设置android studio的某些文件里的参数。首先找到androidstudio的安装目录\bin\studio64.exe.vmoptions这个文件(我的是64位系统,如果你的是32位的系统应该是studio.exe.vmoptions),把它复制到”本账户目录”\.AndroidStudio1.5目录下,先说下这里的”本账户目录”,就是你登录windows的那个账号的目录,如我的是使用Administrator登录的,我的”本账户目录”就C:\Users\Administrator,至于后面的.AndroidStudio1.5是我使用的android studio是1.5的版本,如果你的是别的版本,请参考下图:


然后打开刚刚复制的那个文件如下:

-Xms128m
-Xmx750m
-XX:MaxPermSize=350m
-XX:ReservedCodeCacheSize=96m
-ea
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-Djna.nosys=true
-Djna.boot.library.path=
 
-Djna.debug_load=true
-Djna.debug_load.jna=true
-Djsse.enableSNIExtension=false
-XX:+UseCodeCacheFlushing
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50
-Didea.platform.prefix=AndroidStudio
-Didea.paths.selector=AndroidStudio


 

其中Xms表示JVM Heap(堆内存)最小尺寸,Xmx表示JVM Heap(堆内存)最大允许的尺寸, XX:MaxPermSize表示最大允许非堆内存分配尺寸,可以根据自己的电脑配置的高低来设置这三个值,

例如:

-Xms1024m
-Xmx2048m
-XX:MaxPermSize=1024m


 

其中有一点需要提一下,我看到许多兄弟就直接对androidstudio的安装目录\bin\studio64.exe.vmoptions这个文件进行修改,但我当我打开这个文件时上面提示:

 *DONOT* modify this file directly. If there is a value that you would like tooverride,

 please add it to your user specificconfiguration file.啥意思?就是不让咱们在此文件修改的提示,如果这些参数确实需要修改,自己弄个新的文件在特定的目录(就是我上面方法中的C:\Users\Administrator\.AndroidStudio1.5目录)来覆盖它。为什么不让修改?

官方的解释:

You should not edit any files in the IDEinstallation directory. Instead, you can customize the attributes by creatingyour own .properties or .vmoptions files in the following directories. (Thishas been possible on some platforms before, but it required you to copy andchange the entire contents of the files. With the latest changes theseproperties are now additive instead such that you can set just the attributesyou care about, and the rest will use the defaults from the IDE installation).

 

 

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值