안드로이드 스튜디오는 너무 많은 메모리를 소비
Android Studio 1.0 RC 2를 설치했습니다. 4GB의 RAM이 설치되어 있지만 Android Studio를 시작하고 Android Emulator를 시작한 후이 두 메모리 만 90 % 이상의 실제 메모리를 사용했습니다. 이 메모리 사용을 줄일 수있는 방법이 있습니까? 이 메모리 문제로 인해 다른 응용 프로그램을 동시에 열 수 없습니다.
현재 RAM 6 기가있는 Windows 8.1 컴퓨터에서 Android Studio를 실행하고 있습니다.
안드로이드 스튜디오에서 VCS를 비활성화하고 외부 프로그램을 사용하여 VCS를 처리하는 것이 많은 도움이되었다는 것을 알았습니다. 파일 -> 설정 -> 플러그인 으로 이동하여 VCS를 비활성화하고 다음을 비활성화 할 수 있습니다.
- CVS 통합
- 힘내 통합
- 깃 허브
- 구글 클라우드 테스팅
- Google 클라우드 도구 핵심
- Android Studio 용 Google 클라우드 도구
- hg4idea
- 서브 버전 통합
- 머큐리 통합
- 테스트 NG-J
필자의 경우 메모리 호깅의 두 가지 주요 소스는 IDE와 Gradle입니다.
Android Studio (최대 1.5GB)
IDE의 JVM은 최대 힙 크기를 갖도록 구성되어 있습니다. 메인 인터페이스의 오른쪽 하단에서이를 확인할 수 있습니다.
당신은 편집하여이를 줄일 수 메모리 관련 설정 에 파일 . 예를 들어 최대 힙 크기를 512MB로 변경했습니다..vmoptions
-Xmx512m
불행히도,이 값을 낮추면 가비지 수집을하기 위해 일시적으로 동결되는 Android Studio의 빈도가 증가한다는 것을 알았습니다.
Gradle (최대 1.5GB)
Gradle은 한동안 개발 한 후에도 많은 RAM을 사용할 수 있습니다. Windows는 다음과 같이 표시합니다 Java(TM) Platform SE Binary
.
Gradle JVM 옵션을 변경하여이 문제를 해결할 수 있습니다. 다음을 편집하여 사용자별로 수행 할 수 있습니다 gradle.properties
.
gradle.properties
파일을 열어서 존재하지 않는 경우 작성하십시오.- 윈도우 :
%USERPROFILE%\.gradle\gradle.properties
- 리눅스 / 맥 :
~/.gradle/gradle.properties
- 윈도우 :
org.gradle.jvmargs
필요한 경우 속성을 업데이트하여 만듭니다. 나는 이것을 내 것으로 설정했다.org.gradle.jvmargs=-Xmx256m -XX:MaxPermSize=256m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
최대 힙 크기가 256MB ( -Xmx256m
)로 설정된 소규모 프로젝트의 빌드 성능에 차이가 없습니다 .
이전 Gradle 프로세스가 종료 되도록 Android Studio를 다시 시작해야 할 수도 있습니다 . 그렇지 않으면 둘 다 동시에 실행될 수 있습니다.
에뮬레이터
에뮬레이터가 많은 RAM을 차지하는 것과 관련하여 스크린 샷에는 약 800MB가 걸립니다. 에뮬레이터에 할당 할 RAM 양을 선택할 수 있습니다.
- AVD 편집
- 를 눌러 고급 설정 표시
- Reduce the value of RAM
You can speed up your Eclipse or Android Studio work, you just follow these:
- Use/open single project at a time
- clean your project after running your app in emulator every time
- use mobile/external device instead of emulator
- don't close emulator after using once, use same emulator for running app each time
- Disable VCS by using File->Settings->Plugins and disable the following things :
1.CVS Integration
2.Git Integration
3.GitHub
4.Google Cloud Tools for Android Studio
5.Subversion Integration
I am also using Android Studio with 4-GB installed main memory but following these statements really boost my Android Studio performance.
Android Studio has recently published an official guide for low-memory machines: Guide
If you are running Android Studio on a machine with less than the recommended specifications (see System Requirements), you can customize the IDE to improve performance on your machine, as follows:
Reduce the maximum heap size available to Android Studio: Reduce the maximum heap size for Android Studio to 512Mb.
Update Gradle and the Android plugin for Gradle: Update to the latest versions of Gradle and the Android plugin for Gradle to ensure you are taking advantage of the latest improvements for performance.
Enable Power Save Mode: Enabling Power Save Mode turns off a number of memory- and battery-intensive background operations, including error highlighting and on-the-fly inspections, autopopup code completion, and automatic incremental background compilation. To turn on Power Save Mode, click File > Power Save Mode.
Disable unnecessary lint checks: To change which lint checks Android Studio runs on your code, proceed as follows: Click File > Settings (on a Mac, Android Studio > Preferences) to open the Settings dialog.In the left pane, expand the Editor section and click Inspections. Click the checkboxes to select or deselect lint checks as appropriate for your project. Click Apply or OK to save your changes.
Debug on a physical device: Debugging on an emulator uses more memory than debugging on a physical device, so you can improve overall performance for Android Studio by debugging on a physical device.
Include only necessary Google Play Services as dependencies: Including Google Play Services as dependencies in your project increases the amount of memory necessary. Only include necessary dependencies to improve memory usage and performance. For more information, see Add Google Play Services to Your Project.
Reduce the maximum heap size available for DEX file compilation: Set the javaMaxHeapSize for DEX file compilation to 200m. For more information, see Improve build times by configuring DEX resources.
Do not enable parallel compilation: Android Studio can compile independent modules in parallel, but if you have a low-memory system you should not turn on this feature. To check this setting, proceed as follows: Click File > Settings (on a Mac, Android Studio > Preferences) to open the Settings dialog. In the left pane, expand Build, Execution, Deployment and then click Compiler. Ensure that the Compile independent modules in parallel option is unchecked.If you have made a change, click Apply or OK for your change to take effect.
Turn on Offline Mode for Gradle: If you have limited bandwitch, turn on Offline Mode to prevent Gradle from attempting to download missing dependencies during your build. When Offline Mode is on, Gradle will issue a build failure if you are missing any dependencies, instead of attempting to download them. To turn on Offline Mode, proceed as follows:
Click File > Settings (on a Mac, Android Studio > Preferences) to open the Settings dialog.
In the left pane, expand Build, Execution, Deployment and then click Gradle.
Under Global Gradle settings, check the Offline work checkbox.
Click Apply or OK for your changes to take effect.
I have used all of Sam's recommendations above, but I found that the VM command line options are no longer supported as described. (I received an error when used)
As an alternative, I was able to reduce gradle dramatically by adding the following line to the "gradle.properties" file
org.gradle.jvmargs=-Xms512m -Xmx1024m
As of A.S. ver 1.3, the file is located in the same folder level as "gradle.build".
The above configuration is a "memory stack" of 512 meg, and "memory heap" of 1024 meg.
I tested this on a small project, using settings where both memory sizes were set to 256 meg. It limited the JVM sizes as expected. In all my tests, I restarted A.S. to force the JVM to restart.
Hopefully, this will save others dealing with this issue from getting those "Get yourself a better computer" responses. :-)
To reduce the lag i would recommend the follwing steps
my pc specs : 2 gb ram, processor: intel core2 duo
first kill all background process, if you have server or database running you could stop them first with following commands
sudo service apache2 stop
sudo service mysql stop
Then enable power saving mode in android studio by file>powersaving mode
It could disable background process, and then studio appears to go well
To run Android envirorment on low configuration machine.
- Close the uncessesory web tabs in browser
- For Antivirus users, exclude the build folder which is auto generated
- Android studio have 1.2 Gb default heap can decrease to 512 MB
Help > Edit custom VM options
studio.vmoptions
-Xmx512m
Layouts performace will be speed up
- For Gradle one of the core component in Android studio Mkae sure like right now 3.0beta is latest one
Below tips can affect the code quality so please use with cautions:
Studio contain Power safe Mode when turned on it will close background operations that lint , code complelitions and so on.
You can run manually lint check when needed
./gradlew lint
Most of are using Android emulators on average it consume 2 GB RAM so if possible use actual Android device these will reduce your resource load on your computer. Alternatively you can reduce the RAM of the emulator and it will automatically reduce the virtual memory consumption on your computer. you can find this in virtual device configuration and advance setting.
Gradle offline mode is a feature for bandwidth limited users to disable the downloading of build dependencies. It will reduce the background operation that will help to increase the performance of Android studio.
Android studio offers an optimization to compile multiple modules in parallel. On low RAM machines this feature will likely have a negative impact on the performance. You can disable it in the compiler settings dialog.
I have Android Studio 2.1.1 Bro use genymotion emulator It Faster If Use Android Marshmallow. And My Ram Is 4gb.And Install Plugin for genymotion in Android Studio.You Will see good result in instead of wasting time start android emualtor it will take 5 min.genymotion 10 to 20 second speed and faster so I recommended to you use genymotion.
I fond this YouTube video from Google where are some tips and tricks for it. The video also includes advantages and disadvantages of suggested changes.
Improving Android Studio Performance on Memory-Constrained Machines
Try switching your JVM to eclipse openj9. Its gonna use way less memory. I swapped it and its using 600Mb constantly.
Open below mention path on your system and delete all your avd's (Virtual devices: Emulator)
C:\Users{Username}.android\avd
참고 :-android studio에서만 에뮬레이터를 삭제하면 avd로 잡은 모든 공간이 삭제되지는 않습니다. 따라서 위의 주어진 경로에서 모든 avd를 삭제하고 필요한 경우 새 에뮬레이터를 만듭니다.
참고 URL : https://stackoverflow.com/questions/27176353/android-studio-takes-too-much-memory
'Programing' 카테고리의 다른 글
WinRT가 관리되지 않는 이유는 무엇입니까? (0) | 2020.05.31 |
---|---|
플래그 조합의 플래그가 설정되어 있는지 확인하는 방법은 무엇입니까? (0) | 2020.05.30 |
keytool을 찾아서 실행하는 방법 (0) | 2020.05.30 |
UITableViewCell의 기본 높이는 얼마입니까? (0) | 2020.05.30 |
HTML5의 캔버스 너비와 높이 (0) | 2020.05.30 |