开发者

Java - Heap memory [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicates:

java.lang.OutOfMemoryError: Java heap space

How to deal with “java.lang.O开发者_如何转开发utOfMemoryError: Java heap space” error (64MB heap size)

Could you please tell me how could I increase the java internal heap memory?


Use java -Xms<initial heap size> -Xmx<maximum heap size>

From the manual page:

This value must be a multiple of 1024 greater than 2 MB. Append the letter k or K to indicate kilobytes, the letter m or M to indicate megabytes, the letter g or G to indicate gigabytes, or the letter t or T to indicate terabytes.


Probably you meant increasing the initial or maximum heap memory that the JVM can allocate. This can only be done at the startup time (i-e when your JVM starts up).

JVM accepts argument, often called jvmargs, that let you control various aspects of the JVM instance. For specifying minimum (starting) and maximum heap memory, you can use -Xms and Xmx jvmargs.

The actual process of specifying jvmargs vary depending on how are you launching your java program. If you are launching your program via command-line you can use following pattern:

java -Xms<initial> -Xmx<maximum> <mainClass> <args>

The size can be specified in MB or GB, for example:

java -Xms256M -Xmx2G ...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜