Under Ubuntu system, Eclipse configuration file:
vi ~/eclipse/ -vmargs -Xms128M -Xmx512M -XX:PermSize=64M -XX:MaxPermSize=128M
Here are a few questions:
1. What does each parameter mean?
2. Why do some machines set -Xmx and -XX:MaxPermSize to 512M and Eclipse can be started, but some machines cannot be started?
3. Why does the above parameters be written to the file Eclipse do not perform the corresponding settings?
1. What does each parameter mean?
In the parameters, -vmargs means setting JVM parameters, so the following are actually JVM parameters. Let’s first understand the mechanism of JVM memory management, and then explain the meaning of each parameter.
Heap and non-heap memory
According to the official statement, "The Java virtual machine has a heap, and the heap is the runtime data area, from which the memory of all class instances and arrays is allocated. The heap is created when the Java virtual machine is started. Memory outside the heap in the JVM is called non-heap memory".
It can be seen that the JVM mainly manages two types of memory: heap and non-heap
Simply put: the heap is the memory that is accessible to Java code, which is reserved for developers; non-heap is reserved for JVM for itself, so the method area, memory required for internal processing or optimization of JVM (such as JIT compiled code cache), each class structure (such as runtime constant pool, fields and method data), and the code of method and constructor are all in non-heap memory.
Heap memory allocation
The initial memory allocated by JVM is specified by -Xms, which is 1/64 of physical memory by default; the maximum memory allocated by JVM is specified by -Xmx, which is 1/4 of physical memory by default. When the default free heap memory is less than 40%, the JVM will increase the heap until the maximum limit of -Xmx; when the free heap memory is greater than 70%, the JVM will reduce the heap until the minimum limit of -Xms. Therefore, the server generally sets -Xms and -Xmx equality to avoid adjusting the heap size after each GC.
Non-heap memory allocation
JVM uses -XX:PermSize to set the initial value of non-heap memory, which is 1/64 of physical memory by default; the maximum non-heap memory size is set by XX:MaxPermSize to set the size of the maximum non-heap memory, which is 1/4 of physical memory by default.
JVM memory limit (maximum value)
First of all, JVM memory is limited to the actual maximum physical memory (memory block). Assuming that physical memory is infinitely large, the maximum value of JVM memory has a lot to do with the operating system. Simply put, although the controllable memory space of 32-bit processors has 4GB, the specific operating system will give a limit, which is generally 2GB-3GB (generally 1.5G-2G for Windows systems and 2G-3G for Linux systems), and there will be no limit for processors above 64bit.
2. Why do some machines have Eclipse after setting both -Xmx and -XX:MaxPermSize to 512M, but some machines cannot start?
Through the above introduction to JVM memory management, we have learned that JVM memory includes two types: heap memory and non-heap memory. In addition, the maximum JVM memory depends first on the actual physical memory and operating system. Therefore, setting VM parameters causes the program to fail to start, and there are several main reasons:
1) The value of -Xms in the parameter is greater than -Xmx, or the value of -XX:PermSize is greater than -XX:MaxPermSize;
2) -Xmx value and -XX: The sum of MaxPermSize exceeds the maximum limit of JVM memory, such as the current operating system maximum memory limit, or actual physical memory, etc. Speaking of actual physical memory, one thing we need to make clear is that if your memory is 1024MB, but the one used in the actual system cannot be 1024MB, because some of it is occupied by hardware.
3. Why is the above parameters written to the file? Eclipse does not perform the corresponding settings?
Why are the same parameters valid in shortcuts or command lines but invalid in files? This is because we do not follow the file setting rules:
Parameters are like "item value". If there are spaces in the middle, you need to write in line. If there are spaces in the value, you need to include them in double quotes. For example, we use the -vm C:\Java\jre1.6.0\bin\ parameter to set the virtual machine, and write it in the file as follows:
-vm
C:\Java\jre1.6.0\bin\
According to what is mentioned above, the final parameters can be written like this:
-vmargs -Xms128M -Xmx512M -XX:PermSize=64M -XX:MaxPermSize=128M
The actual running results can be viewed through the "Configuration Details" button in the "Help"-"About Eclipse SDK" window in Eclipse.
It should be noted that the file contents included in the Eclipse compression package are as follows:
-showsplash -- 256m -vmargs -Xms40m -Xmx256m
Among them, - (note that the first one is the two connecting lines) and -XX:MaxPermSize parameters are basically the same. I think the only difference is that the former is the parameter set at startup, while the latter is the parameter in the JVM used by eclipse. In fact, just set one of the two, so here you can comment out the - and the next line using #.
4. Other startup parameters.
If you have a dual-core CPU, maybe you can try this parameter:
-XX:+UseParallelGC
Make GC execute faster (just new parameters added to GC in JDK 5)
Example (16G physical memory):
-startup plugins/.launcher_1.3.0. -- plugins/.x86_64_1.1.200.v20120913-144807 -product -- openFile -showsplash -- m -- openFile -vmargs -=1.5 -=standard -XX:PermSize=64m -XX:MaxPermSize=512m -XX:+UseParallelGC -Xms512m -Xmx2048m
eclipse error log directory: Find the workspace you specified ->.metadata->.log
Summarize
The above is the details of the ini settings under eclipse introduced to you by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support for my website!