This question already has an answer here:
这个问题已经有了答案:
- Increase heap size in Java 11 answers
- 在Java 11中增加堆大小
HI, I like to know can I increase the memory of the JVM depending on my application.If yes how can I increase the JVM memory? And how can I know the size of JVM?
嗨,我想知道是否可以根据我的应用程序增加JVM的内存。如果是,如何增加JVM内存?我怎么知道JVM的大小呢?
4 个解决方案
#1
86
When starting the JVM, two parameters can be adjusted to suit your memory needs :
启动JVM时,可以调整两个参数,以适应您的内存需求:
-Xms<size>
specifies the initial Java heap size and
指定初始的Java堆大小和
-Xmx<size>
the maximum Java heap size.
最大Java堆大小。
http://www.rgagnon.com/javadetails/java-0131.html
http://www.rgagnon.com/javadetails/java - 0131. - html
#2
14
If you are using Eclipse then you can do this by specifying the required size for the particular application in its Run Configuration's VM Arguments as EX: -Xms128m -Xmx512m
如果您正在使用Eclipse,那么可以在运行配置的VM参数中指定特定应用程序所需的大小,如:-Xms128m -Xmx512m
Or if you want all applications running from your eclipse to have the same specified size then you can specify this in the eclipse.ini
file which is present in your Eclipse home directory.
或者,如果希望从eclipse运行的所有应用程序具有相同的指定大小,则可以在eclipse中指定。在Eclipse主目录中存在的ini文件。
To get the size of the JVM during Runtime you can use Runtime.totalMemory()
which returns the total amount of memory in the Java virtual machine, measured in bytes.
要在运行时获得JVM的大小,可以使用Runtime. totalmemory(),它返回Java虚拟机中以字节为单位的内存总量。
#3
7
When calling java use the -Xmx Flag for example -Xmx512m for 512 megs for the heap size. You may also want to consider the -xms flag to start the heap larger if you are going to have it grow right from the start. The default size is 128megs.
当调用java时,使用-Xmx标志(例如-Xmx512m)表示堆大小为512兆。如果要让堆从一开始就增长,您可能还需要考虑-xms标志,使堆开始变得更大。默认大小是128兆。
#4
1
Right click on project -> Run As -> Run Configurations..-> Select Arguments tab -> In VM Arguments you can increase your JVM memory allocation. Java HotSpot document will help you to setup your VM Argument HERE
右键点击项目->运行为->运行配置。->选择Arguments tab ->在VM参数中可以增加JVM内存分配。Java HotSpot文档将帮助您在这里设置VM参数
I will not prefer to make any changes into eclipse.ini as minor mistake cause lot of issues. It's easier to play with VM Args
我不想对eclipse做任何更改。ini作为一个小错误会引起很多问题。使用VM Args更容易
#1
86
When starting the JVM, two parameters can be adjusted to suit your memory needs :
启动JVM时,可以调整两个参数,以适应您的内存需求:
-Xms<size>
specifies the initial Java heap size and
指定初始的Java堆大小和
-Xmx<size>
the maximum Java heap size.
最大Java堆大小。
http://www.rgagnon.com/javadetails/java-0131.html
http://www.rgagnon.com/javadetails/java - 0131. - html
#2
14
If you are using Eclipse then you can do this by specifying the required size for the particular application in its Run Configuration's VM Arguments as EX: -Xms128m -Xmx512m
如果您正在使用Eclipse,那么可以在运行配置的VM参数中指定特定应用程序所需的大小,如:-Xms128m -Xmx512m
Or if you want all applications running from your eclipse to have the same specified size then you can specify this in the eclipse.ini
file which is present in your Eclipse home directory.
或者,如果希望从eclipse运行的所有应用程序具有相同的指定大小,则可以在eclipse中指定。在Eclipse主目录中存在的ini文件。
To get the size of the JVM during Runtime you can use Runtime.totalMemory()
which returns the total amount of memory in the Java virtual machine, measured in bytes.
要在运行时获得JVM的大小,可以使用Runtime. totalmemory(),它返回Java虚拟机中以字节为单位的内存总量。
#3
7
When calling java use the -Xmx Flag for example -Xmx512m for 512 megs for the heap size. You may also want to consider the -xms flag to start the heap larger if you are going to have it grow right from the start. The default size is 128megs.
当调用java时,使用-Xmx标志(例如-Xmx512m)表示堆大小为512兆。如果要让堆从一开始就增长,您可能还需要考虑-xms标志,使堆开始变得更大。默认大小是128兆。
#4
1
Right click on project -> Run As -> Run Configurations..-> Select Arguments tab -> In VM Arguments you can increase your JVM memory allocation. Java HotSpot document will help you to setup your VM Argument HERE
右键点击项目->运行为->运行配置。->选择Arguments tab ->在VM参数中可以增加JVM内存分配。Java HotSpot文档将帮助您在这里设置VM参数
I will not prefer to make any changes into eclipse.ini as minor mistake cause lot of issues. It's easier to play with VM Args
我不想对eclipse做任何更改。ini作为一个小错误会引起很多问题。使用VM Args更容易