简体   繁体   English

增加堆大小

[英]Increasing Heap Size

I have read various posts in stackoverflow and I am trying to figure out how to increase my heap size for my JVM.我已经阅读了 stackoverflow 中的各种帖子,我正试图弄清楚如何增加我的 JVM 的堆大小。 I know that the command -vmargs -Xms256m -Xmx4096m will increase the heap size.我知道命令-vmargs -Xms256m -Xmx4096m会增加堆大小。 But it is not working, or I don't know how to use the command.但它不起作用,或者我不知道如何使用该命令。 I read that I should go to the JVM folder and type this command but I cant locate Java in my Virtual machine.我读到我应该转到 JVM 文件夹并键入此命令,但我无法在我的虚拟机中找到 Java。

I also read that I can do it by changing the values in the eclipse.ini file but I am not able to find anything related to heapsize in my file.我还读到我可以通过更改 eclipse.ini 文件中的值来做到这一点,但我无法在我的文件中找到与堆大小相关的任何内容。 I can do a grep java and find out that my heap size is 324m.我可以做一个 grep java 并发现我的堆大小是 324m。

Can someone guide me for where and how I should increase the heap size?有人可以指导我在哪里以及如何增加堆大小吗?

It depends on what application that you are trying to launch.这取决于您尝试启动的应用程序。

If you are running your java code from commandline using java executable, then you can simply pass these parameters as argument to java executable.如果您使用java可执行文件从命令行运行 java 代码,那么您可以简单地将这些参数作为参数传递给 java 可执行文件。

java -Xms256m -Xmx2096m <main class>

If you want increase Eclipse's JVM memory, then you can update eclipse.ini by appending following lines to the end of file.如果您想增加 Eclipse 的 JVM 内存,那么您可以通过将以下几行附加到文件末尾来更新 eclipse.ini。

-Xms256m
-Xmx4906m

For any software which uses JVM (like tomcat, weblogic etc), you need to follow their documentation to set JVM arguments.对于任何使用 JVM 的软件(如 tomcat、weblogic 等),您需要按照他们的文档来设置 JVM 参数。 Usually, they will provide startup script where you will have option to set the JVM arguments.通常,他们会提供启动脚本,您可以在其中选择设置 JVM 参数。

If you are using Scala, as suggested by the tag, you use -J as a prefix to the arguments that must be passed to Java.如果您使用的是 Scala,那么按照标记的建议,您可以使用-J作为必须传递给 Java 的参数的前缀。 Like this:像这样:

scala -J-Xms256m -J-Xmx4096m

This would run the interpreter with 256 megabytes of initial memory, and 4 gigabytes maximum memory.这将使用 256 MB 的初始内存和 4 GB 的最大内存来运行解释器。

The same thing can be used with scalac and fsc .同样的事情可以与scalacfsc一起使用。

Now, if you are using java to run stuff, you just pass them directly:现在,如果您使用java来运行东西,您只需直接传递它们:

java -Xms256m -Xmx4096m <some other stuff>

If you are using something else, please say what you are using, otherwise we can't help you.如果您正在使用其他东西,请说出您正在使用的内容,否则我们无法为您提供帮助。

You could try this:你可以试试这个:

java -Xms64m -Xmx256m HelloWorld

Where HelloWorld is replaced with your application and the other arguments are customized to your liking! HelloWorld 替换为您的应用程序,其他参数根据您的喜好自定义!

Source: http://viralpatel.net/blogs/jvm-java-increase-heap-size-setting-heap-size-jvm-heap/来源: http : //viralpatel.net/blogs/jvm-java-increase-heap-size-setting-heap-size-jvm-heap/

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

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