简体   繁体   English

增加Java堆大小

[英]Increasing Java Heap Size

I'm trying to increase value of heap size of my jvm, but it doesn't work. 我试图增加我的jvm的堆大小的值,但是它不起作用。 Could anybody help me with this geek problem? 有人可以帮我解决这个怪胎问题吗? My configuration are follow: Windows 7 x64, 4 GB, i3 CPU 我的配置如下:Windows 7 x64、4 GB,i3 CPU

在此处输入图片说明

在此处输入图片说明

When I try something like -Xmx2000M I have nothing 当我尝试类似-Xmx2000M的东西时,我什么也没有 在此处输入图片说明

Where are my errors? 我的错误在哪里?

I think you are expecting this. 我认为您对此有所期待。

$ java -Xmx2000M -Xms1000M -XshowSettings:all $ java -Xmx2000M -Xms1000M -XshowSettings:all

VM settings:
   Min. Heap Size: 1000.00M
   Max. Heap Size: 1.95G
   Ergonomics Machine Class: server
   Using VM: Java HotSpot(TM) 64-Bit Server VM

Your command is half correct. 您的命令是正确的一半。 You need to specify what you want to run with an increased heap size. 您需要指定要在增大的堆大小下运行的内容。 Something like this 像这样

java -Xmx2000M -Xms1000M -jar <jar-file-name>.jar

You need to provide something for JVM to run with these new settings. 您需要提供一些使JVM与这些新设置一起运行的功能。

The arguments you are using only configure the JVM, it still needs whatever jar or class file you want to run. 您使用的参数仅配置JVM,它仍然需要您要运行的任何jar或类文件。

To permanently configure JVM profile on windows, follow these Instructions . 要在Windows上永久配置JVM配置文件,请遵循以下说明 The settings tool will let you edit runtime parameters: 设置工具将使您可以编辑运行时参数:

在此处输入图片说明

you need to specify as well which class/jar you want to run. 您还需要指定要运行的类/ jar。 You cannot just increase the heap size per default for all java pplications. 您不能只为所有Java应用程序默认增加堆大小。 Instead you have to edit the command line of the program you are trying to run. 相反,您必须编辑要运行的程序的命令行。

The error you have got in the last screen shot is about unavailability of the class file to run. 您在上一个屏幕快照中遇到的错误是有关无法运行类文件的。
You should provide class file which includes main function while running java command. 您应该在运行Java命令时提供包含主要功能的类文件。

java -Xmx2000M -Xms1000m MyClass

Considering you have MyClass.class in your classpath. 考虑到您的类路径中有MyClass.class。

may be I am late) But I think you can use it. 可能我迟到了),但我认为您可以使用它。 In IDEA choose Edit Configuration... on drop-down list(look on picture below). 在IDEA中Edit Configuration...从下拉列表中选择Edit Configuration... (在下面的图片中查看)。 And then type in VM Options your parameters -Xmx2000M -Xms1000M . 然后在VM Options您的参数-Xmx2000M -Xms1000M How to find Edit Configuration on IDEA 如何在IDEA上找到编辑配置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM