Android Development Eclipse Memory tuning

Source: Internet
Author: User
Tags xms

In the process of using Eclipse , there are times when there is not enough memory to use the Java virtual machine, and Eclipse will prompt you to restart, and we can set the eclipse Start parameters to adjust the use of Java virtual machine memory.



Right-click the Eclipse shortcut, select Properties, add -vmargs-xmx192mto the target Text , set initialize to use Java virtual machine maximum memory 192M, can also be set to other values.
-XMX This parameter is set to use the maximum memory
-XMS This parameter is set to use the minimum memory
Two parameters can be used at the same time, or can be used alone.

With compile times memory is not enough , turn over the information , the problem and solve the following :
Sometimes the compile times heap is not enough and can be changed in the following ways :
It is not enough to do large-scale development.

For large-scale development, you should modify the VM argument to make more heaps available.

For example, the following settings will allow the Java heap to grow to 256MB:
-vmargs-xmx256m
The corresponding settings in Eclipse are : Windows- a preferences ->java-> installed JRE, in the default VM Increase in arguments :-xmx256m

Cause: TheJava virtual machine allocates 64M of memory by default, and if your application is larger and exceeds 64M of memory, theJava virtual machine will throw OutOfMemoryError, and stop running. No matter what application (Web app,application , etc.), just modify the run Java command on your machine and add it in the javaxxx command -XMS ( Minimum memory usage ),-xmx(maximum memory usage) can be resolved. Of course, the memory capacity here refers to the physical memory, not exceeding the total capacity of your machine's physical memory.


Parameters in-vmargsThe meaning is to setJVMParameters, so the following are actuallyJVMParameters, let's first look atJVMThe mechanism of memory management, and then explain what each parameter represents.

Heap and non-heap (non-heap) memory

According to the official statement, "Java virtual machines have a heap, the heap is a runtime data region, and all class instances and arrays of memory are allocated from here." Heap is inJavaCreated when the virtual machine is started. "" InJVMMemory outside of the heap is called Non-heap memory (Non-heap Memory)”。 Can seeJVMTwo types of memory are primarily managed: heap and non-heap. Simply put, the heap is the Java code of memory that is left to the developers, not the heap isJVMLeft to themselves, so the method area,JVMThe memory required for internal processing or optimization, such as the JIT-compiled code cache, and the code for each class structure (such as running a constant pool, fields, and method data), and methods and construction methods, are in non-heap memory.

  Heap memory allocation
JVM
The initial allocated memory is determined by the-xmsSpecifies that the default is 1/64 of the physical memory;JVMThe maximum allocated memory is determined by the-xmxSpecifies that the default is 1/4 of physical memory. When the default free heap memory is less than 40%,JVMIt will increase the heap until-xmxWhen the free heap memory is greater than 70%,JVMWill reduce the heap until-xmsThe minimum limit. So server general settings-xms-xmxEqual to avoid eachGCThe size of the heap after resizing.


  non-heap memory allocation
JVM
Use-xx:permsizeSets the non-heap memory initial value, which defaults to 1/64 of the physical memory;xx:maxpermsizeSets the maximum non-heap memory size, which is the default for physical memory Quarter

  JVM Memory Limit (max)
First of allJVMMemory is limited to the actual maximum physical memory (nonsense! hehe), assuming that the physical memory is infinitely large,JVMThe maximum memory value is very much related to the operating system. Simply put, the 32-bit processor, although the controllable memory space has4GB,But the specific operating system will give a limit, this limit is generally2GB-3GB (generally under Windows System is 2g-3g under the 1.5g-2g,linux system),and64bitThere is no limit to the processors above.

  PS: When it does not work, it is because we do not comply with the Eclipse.ini file setting rules:
Parameter shape such as "Item Value" In this form, there are spaces in the middle of the need to write a newline, if there are spaces in the value need to be enclosed in double quotation marks. For example, we use-VM C:javajre1.6.0injavaw.exeParameters to set the virtual machine in theEclipse.iniThe file should be written like this:

  -VM
The results of the actual operation can beEclipseIn"Help " – "About Eclipse SDK"Inside the window"Configuration Details"button to view it.



Android Development Eclipse Memory tuning

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.