Example analysis of memory problems in configuring eclipse.ini in java
This article is a detailed analysis and introduction to the problem of eclipse.ini memory settings. Friends in need can refer to it
-vmargs -Xms128M -Xmx512M -XX:PermSize=64M -XX:MaxPermSize=128M
There are several questions here:
1. What are the meanings of each parameter?
2. Why can Eclipse start on some machines after I set both -Xmx and -XX:MaxPermSize to 512M, but cannot on some machines?
3. Why does Eclipse not perform the corresponding settings when writing the above parameters to the eclipse.ini file?
Let’s answer them one by one
1. What is the meaning of each parameter?
-vmargs in the parameters means setting JVM parameters, so the following are actually JVM parameters. We 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. The heap is the runtime data area, and the memory of all class instances and arrays is allocated from here. . The heap is created when the Java virtual machine starts. "The 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 accessible to Java code and is reserved for developers; the non-heap is the memory reserved for the JVM for its own use, so the memory required for method area and JVM internal processing or optimization (such as JIT compiled code cache), every class structure (such as the runtime constant pool, field and method data), and the code for methods and constructors are all in off-heap memory.
Heap memory allocation
The initial memory allocated by the JVM is specified by -Xms, and the default is 1/64 of the physical memory; the maximum memory allocated by the JVM is specified by -Xmx, and the default is 1/4 of the physical memory. By default, when the 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 to be equal 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, the default is 1/64 of physical memory; XX:MaxPermSize sets the maximum size of non-heap memory, the default is 1/64 of physical memory /4.
JVM memory limit (maximum value)
First of all, JVM memory is limited to the actual maximum physical memory (nonsense! Haha). Assuming that the physical memory is infinite, the maximum value of JVM memory has a lot to do with the operating system. To put it simply, although the controllable memory space of a 32-bit processor is 4GB, the specific operating system will set a limit. This limit is generally 2GB-3GB (generally speaking, it is 1.5G-2G under Windows systems and 1.5G-2G under Linux systems). 2G-3G), and there will be no restrictions on processors above 64bit.
2. Why can Eclipse start on some machines after I set both -Xmx and -XX:MaxPermSize to 512M, but cannot on some machines?
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 memory of JVM first depends on the actual physical memory and operating system. Therefore, setting VM parameters causes the program to fail to start mainly for the following 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) The sum of the value of -Xmx and -XX:MaxPermSize exceeds the maximum limit of JVM memory, such as the maximum memory limit of the current operating system, or actual physical memory, etc. Speaking of actual physical memory, one thing to note here is that if your memory is 1024MB, it may not be 1024MB used in the actual system, because part of it is occupied by the hardware.
3. Why does Eclipse not perform the corresponding settings when writing the above parameters to the eclipse.ini file?
Then why are the same parameters valid in shortcuts or command lines but invalid in the eclipse.ini file? This is because we did not follow the setting rules of the eclipse.ini file:
The parameters are in the form of "item value". If there are spaces in the middle, they need to be written in a new line. If there are spaces in the value, they need to be enclosed in double quotes. For example, we use the -vm C:\Java\jre1.6.0\bin\javaw.exe parameter to set up the virtual machine. In the eclipse.ini file, it should be written like this:
-vm
C:\Java\ jre1.6.0\bin\javaw.exe
As mentioned above, the final parameters can be written like this in eclipse.ini:
-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.
In addition, it should be noted that the content of the eclipse.ini file that comes with the Eclipse compressed package is as follows:
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
-vmargs
-Xms40m
-Xmx256m
The meaning of –launcher.XXMaxPermSize (note that there are two connecting lines at the front) and -XX:MaxPermSize parameters are basically the same, I think the only one The difference is that the former is the parameter set when eclipse.exe is started, 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 –launcher.XXMaxPermSize and the next line with #.
3. Other startup parameters. If you have a dual-core CPU, maybe try this parameter:
-XX:+UseParallelGC
to make the GC execute faster. (Just a newly added parameter for GC in JDK 5)
The above is the detailed content of Example analysis of memory problems in configuring eclipse.ini in java. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Guide to Perfect Number in Java. Here we discuss the Definition, How to check Perfect number in Java?, examples with code implementation.

Guide to Weka in Java. Here we discuss the Introduction, how to use weka java, the type of platform, and advantages with examples.

Guide to Smith Number in Java. Here we discuss the Definition, How to check smith number in Java? example with code implementation.

In this article, we have kept the most asked Java Spring Interview Questions with their detailed answers. So that you can crack the interview.

Java 8 introduces the Stream API, providing a powerful and expressive way to process data collections. However, a common question when using Stream is: How to break or return from a forEach operation? Traditional loops allow for early interruption or return, but Stream's forEach method does not directly support this method. This article will explain the reasons and explore alternative methods for implementing premature termination in Stream processing systems. Further reading: Java Stream API improvements Understand Stream forEach The forEach method is a terminal operation that performs one operation on each element in the Stream. Its design intention is

Guide to TimeStamp to Date in Java. Here we also discuss the introduction and how to convert timestamp to date in java along with examples.

Capsules are three-dimensional geometric figures, composed of a cylinder and a hemisphere at both ends. The volume of the capsule can be calculated by adding the volume of the cylinder and the volume of the hemisphere at both ends. This tutorial will discuss how to calculate the volume of a given capsule in Java using different methods. Capsule volume formula The formula for capsule volume is as follows: Capsule volume = Cylindrical volume Volume Two hemisphere volume in, r: The radius of the hemisphere. h: The height of the cylinder (excluding the hemisphere). Example 1 enter Radius = 5 units Height = 10 units Output Volume = 1570.8 cubic units explain Calculate volume using formula: Volume = π × r2 × h (4

Java is a popular programming language that can be learned by both beginners and experienced developers. This tutorial starts with basic concepts and progresses through advanced topics. After installing the Java Development Kit, you can practice programming by creating a simple "Hello, World!" program. After you understand the code, use the command prompt to compile and run the program, and "Hello, World!" will be output on the console. Learning Java starts your programming journey, and as your mastery deepens, you can create more complex applications.
