search
HomeJavajavaTutorialExample 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!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Why can't the main class be found after copying and pasting the package in IDEA? Is there any solution?Why can't the main class be found after copying and pasting the package in IDEA? Is there any solution?Apr 19, 2025 pm 07:57 PM

Why can't the main class be found after copying and pasting the package in IDEA? Using IntelliJIDEA...

Java multi-interface call: How to ensure that interface A is executed before interface B is executed?Java multi-interface call: How to ensure that interface A is executed before interface B is executed?Apr 19, 2025 pm 07:54 PM

State synchronization between Java multi-interface calls: How to ensure that interface A is called after it is executed? In Java development, you often encounter multiple calls...

In Java programming, how to stop subsequent code execution when student ID is repeated?In Java programming, how to stop subsequent code execution when student ID is repeated?Apr 19, 2025 pm 07:51 PM

How to stop subsequent code execution when ID is repeated in Java programming. When learning Java programming, you often encounter such a requirement: when a certain condition is met,...

Ultimate consistency: What business scenarios are applicable to? How to ensure the consistency of the final data?Ultimate consistency: What business scenarios are applicable to? How to ensure the consistency of the final data?Apr 19, 2025 pm 07:48 PM

In-depth discussion of final consistency: In the distributed system of application scenarios and implementation methods, ensuring data consistency has always been a major challenge for developers. This article...

After the Spring Boot service is running for a period of time, how to troubleshoot?After the Spring Boot service is running for a period of time, how to troubleshoot?Apr 19, 2025 pm 07:45 PM

The troubleshooting idea of ​​SSH connection failure after SpringBoot service has been running for a period of time has recently encountered a problem: a Spring...

How to push the video stream of Hikvision camera SDK to the front-end Vue project for real-time playback?How to push the video stream of Hikvision camera SDK to the front-end Vue project for real-time playback?Apr 19, 2025 pm 07:42 PM

How to push video streams from Hikvision camera SDK to front-end Vue project? During the development process, you often encounter videos that need to be captured by the camera to be circulated...

How to limit access to access_token via OAuth2.0 scope parameter?How to limit access to access_token via OAuth2.0 scope parameter?Apr 19, 2025 pm 07:39 PM

How to use access_token of OAuth2.0 to restrict interface access permissions How to ensure access_token when authorizing using OAuth2.0...

In Spring Boot Redis, how to solve the problem of returning garbled codes?In Spring Boot Redis, how to solve the problem of returning garbled codes?Apr 19, 2025 pm 07:36 PM

SpringBootRedis gets the key garbled problem analysis using Spring...

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.