android studio 占用太多内存

Reduce Build Process Heap Size in Android Studio

Go to File->Other Settings->Default Settings->Build, Execution, Deployment->Compiler

Change the Build Process Heap Size to a smaller amount like 512 MB from the default size of 700 MB.

Reduce Android Studio Memory Usage

Edit: From 1.3 onwards, this needs to be set on a per project basis (don’t know why they did this):

Android Studio Prompt

Reduce DEX Compiler Heap Size

File->Other Settings->Default Settings->Build, Execution, Deployment->Compiler->Android Compiler

You can again reducteAndroid Studio Memory Usage by reducing the DEX Compiler’s Maximum heap size by changing the default value of 700 MB to a lower value like 400 MB. Again this will marginally slow build and deploy time but will reduce Android Studio’s RAM memory consumption.

Reduce Android Studio DEX Compiler Memory Usage

Disable VCS in Android Studio

Disabling VCS in android studio and using an external program to handle VCS helped some users a lot. You can disable VCS by going to File->Settings->Plugins and disable the following:

  • CVS Integration
  • Git Integration
  • GitHub
  • Google Cloud Tools for Android Studio
  • Subversion Integration

Limit JVM Size Used by Gradle

File->Other Settings->Default Settings->Build, Execution, Deployment->Compiler->Compiler

Limit the size of the Java Virtual Machine used by Gradle. You can do this by entering “-Xmx256m” in the VM Options field. This will slow down the compilation process but save immense memory. The increase in compilation time for a small project was negligible (~10 seconds).

Reduce Android Studio Gradle Memory Usage


展开阅读全文

内存占用太多,为什么?

03-17

哪位能不能帮我优化一下?我这个程序不知道为什么,占用了很大的内存,速度很慢rntypedef struct AListrnrn int no1;rn int no2;rn int no3;rn int no4;rn int no5;rn rn TAList;rntypedef TAList* PAList;rnrnrnvoid __fastcall TForm1::FormCreate(TObject *Sender)rnrn randomize();rn ResultList = new TList; rnrnrnvoid __fastcall TForm1::Button1Click(TObject *Sender)rnrn DWORD StartTime,EndTime,LastTime;rn StartTime=GetTickCount(); //从这开始计算下面这个循环运行的时间rn for(int i=0;i<100000;i++)rn rn PAList AStruct;rn AStruct = new TAList;rn AStruct->no1=random(10);rn AStruct->no2=random(10);rn AStruct->no3=random(10);rn AStruct->no4=random(10);rn AStruct->no5=random(10);rn ResultList->Add(AStruct);rnrn rn //开始比较,此处占用了极多的内存rn for(int i=0;iResultList->Count-1;i++)rn rn PAList AStruct;rn AStruct = new TAList;rn AStruct = (PAList) ResultList->Items[i];rn for(int j=i+1;jResultList->Count;j++)rn rn PAList BStruct;rn BStruct = new TAList;rn BStruct = (PAList) ResultList->Items[j];rn int iSame=0;rn if(AStruct->no1==(BStruct->no1+1)) continue;rn if(AStruct->no2==(BStruct->no2+1)) continue;rn if(AStruct->no3==(BStruct->no3+1)) continue;rn if(AStruct->no4==(BStruct->no4+1)) continue;rn if(AStruct->no5==(BStruct->no5+1)) continue;rnrn if(AStruct->no1==(BStruct->no1+2)) continue;rn if(AStruct->no2==(BStruct->no2+2)) continue;rn if(AStruct->no3==(BStruct->no3+2)) continue;rn if(AStruct->no4==(BStruct->no4+2)) continue;rn if(AStruct->no5==(BStruct->no5+2)) continue;rnrn ResultList->Delete(j);j--; rn delete BStruct;rn rnrn rnrnEndTime=GetTickCount(); //循环结束,计时也结束rnLastTime=EndTime-StartTime;rnApplication->MessageBoxA(IntToStr(LastTime).c_str(),"运算时间",MB_ICONEXCLAMATION); rnrnrnvoid __fastcall TForm1::FormDestroy(TObject *Sender)rnrn if(ResultList->Count>0)rn for(int i=ResultList->Count-1;i<-1;i--)rn rn PAList AStruct;rn AStruct = new TAList;rn AStruct =(PAList) ResultList->Items[i];rn ResultList->Delete(i); rn delete[] AStruct;rnrn rnrn 论坛

没有更多推荐了,返回首页