Trouble increasing Java max heap size












0















I'm very new to Linux (and haven't done much with cmd line in Windows either), and I'm needing to increase my Java heap size to 3GB from 850MB (total of 4GB of RAM on the box).



I've looked at a couple sites for guidance on increasing my heap size, but none of the commands I've taken from them seem to be working.



For reference I've looked at:




  • How do I change Java Runtime Parameters?


  • How to increase JAVA Heap Size?


  • Find out your Java heap memory size


  • JAVA_OPTS for increasing heap size



Based on the information in those questions, I've tried the following commands:



java -Xmx3072m
java -Xmx3g
java JAVA_OPTS="-Xmx3g"
JAVA_OPTS="-Xmx3g"


After each I get no errors (except the third command, that one errors), but when I run `










share|improve this question
















bumped to the homepage by Community 10 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • What java program are you trying to run? All of the options you gave just run the JVM without running any program.

    – Cris Holdorph
    Jul 17 '15 at 20:22
















0















I'm very new to Linux (and haven't done much with cmd line in Windows either), and I'm needing to increase my Java heap size to 3GB from 850MB (total of 4GB of RAM on the box).



I've looked at a couple sites for guidance on increasing my heap size, but none of the commands I've taken from them seem to be working.



For reference I've looked at:




  • How do I change Java Runtime Parameters?


  • How to increase JAVA Heap Size?


  • Find out your Java heap memory size


  • JAVA_OPTS for increasing heap size



Based on the information in those questions, I've tried the following commands:



java -Xmx3072m
java -Xmx3g
java JAVA_OPTS="-Xmx3g"
JAVA_OPTS="-Xmx3g"


After each I get no errors (except the third command, that one errors), but when I run `










share|improve this question
















bumped to the homepage by Community 10 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • What java program are you trying to run? All of the options you gave just run the JVM without running any program.

    – Cris Holdorph
    Jul 17 '15 at 20:22














0












0








0








I'm very new to Linux (and haven't done much with cmd line in Windows either), and I'm needing to increase my Java heap size to 3GB from 850MB (total of 4GB of RAM on the box).



I've looked at a couple sites for guidance on increasing my heap size, but none of the commands I've taken from them seem to be working.



For reference I've looked at:




  • How do I change Java Runtime Parameters?


  • How to increase JAVA Heap Size?


  • Find out your Java heap memory size


  • JAVA_OPTS for increasing heap size



Based on the information in those questions, I've tried the following commands:



java -Xmx3072m
java -Xmx3g
java JAVA_OPTS="-Xmx3g"
JAVA_OPTS="-Xmx3g"


After each I get no errors (except the third command, that one errors), but when I run `










share|improve this question
















I'm very new to Linux (and haven't done much with cmd line in Windows either), and I'm needing to increase my Java heap size to 3GB from 850MB (total of 4GB of RAM on the box).



I've looked at a couple sites for guidance on increasing my heap size, but none of the commands I've taken from them seem to be working.



For reference I've looked at:




  • How do I change Java Runtime Parameters?


  • How to increase JAVA Heap Size?


  • Find out your Java heap memory size


  • JAVA_OPTS for increasing heap size



Based on the information in those questions, I've tried the following commands:



java -Xmx3072m
java -Xmx3g
java JAVA_OPTS="-Xmx3g"
JAVA_OPTS="-Xmx3g"


After each I get no errors (except the third command, that one errors), but when I run `







java






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 23 '17 at 12:39









Community

1




1










asked Jul 17 '15 at 18:24









JMichaelJMichael

10326




10326





bumped to the homepage by Community 10 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 10 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • What java program are you trying to run? All of the options you gave just run the JVM without running any program.

    – Cris Holdorph
    Jul 17 '15 at 20:22



















  • What java program are you trying to run? All of the options you gave just run the JVM without running any program.

    – Cris Holdorph
    Jul 17 '15 at 20:22

















What java program are you trying to run? All of the options you gave just run the JVM without running any program.

– Cris Holdorph
Jul 17 '15 at 20:22





What java program are you trying to run? All of the options you gave just run the JVM without running any program.

– Cris Holdorph
Jul 17 '15 at 20:22










1 Answer
1






active

oldest

votes


















0














Via



java -Xmx3072m <your_class_name>


or



java -Xmx3072m -jar <your_jar_file>


or



JAVA_OPTS="-Xmx3G"
java "$JAVA_OPTS" -jar <your_jar_file>




Example



% java -Xmx80m -XshowSettings:all -jar HelloWorld.jar

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





all described in man java



-Xmxsize
Specifies the maximum size (in bytes) of the memory allocation pool
in bytes. This value must be a multiple of 1024 and greater than
2 MB. Append the letter k or K to indicate kilobytes, m or M to
indicate megabytes, g or G to indicate gigabytes. The default
value is chosen at runtime based on system configuration. For server
deployments, -Xms and -Xmx are often set to the same value. See the
section "Ergonomics" in Java SE HotSpot Virtual Machine Garbage
Collection Tuning Guide at
http://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/index.html.

The following examples show how to set the maximum allowed size of
allocated memory to 80 MB using various units:

-Xmx83886080
-Xmx81920k
-Xmx80m

The -Xmx option is equivalent to -XX:MaxHeapSize.






  • java JAVA_OPTS="-Xmx3g"



    Can't work, JAVA_OPTS= … isn't a valid parameter for java




  • JAVA_OPTS="-Xmx3g"



    Works, but useless in your case, because you define an environment variable without using it, eg:



    % JAVA_OPTS="-Xmx3g"
    % echo $JAVA_OPTS
    -Xmx3g







share|improve this answer





















  • 2





    As long as you have 64 bit Ubuntu installed this should work perfectly, if you have a 32 bit OS installed the max RAM any program can use is 2GB

    – Wargog
    Jul 17 '15 at 19:20











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f649627%2ftrouble-increasing-java-max-heap-size%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Via



java -Xmx3072m <your_class_name>


or



java -Xmx3072m -jar <your_jar_file>


or



JAVA_OPTS="-Xmx3G"
java "$JAVA_OPTS" -jar <your_jar_file>




Example



% java -Xmx80m -XshowSettings:all -jar HelloWorld.jar

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





all described in man java



-Xmxsize
Specifies the maximum size (in bytes) of the memory allocation pool
in bytes. This value must be a multiple of 1024 and greater than
2 MB. Append the letter k or K to indicate kilobytes, m or M to
indicate megabytes, g or G to indicate gigabytes. The default
value is chosen at runtime based on system configuration. For server
deployments, -Xms and -Xmx are often set to the same value. See the
section "Ergonomics" in Java SE HotSpot Virtual Machine Garbage
Collection Tuning Guide at
http://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/index.html.

The following examples show how to set the maximum allowed size of
allocated memory to 80 MB using various units:

-Xmx83886080
-Xmx81920k
-Xmx80m

The -Xmx option is equivalent to -XX:MaxHeapSize.






  • java JAVA_OPTS="-Xmx3g"



    Can't work, JAVA_OPTS= … isn't a valid parameter for java




  • JAVA_OPTS="-Xmx3g"



    Works, but useless in your case, because you define an environment variable without using it, eg:



    % JAVA_OPTS="-Xmx3g"
    % echo $JAVA_OPTS
    -Xmx3g







share|improve this answer





















  • 2





    As long as you have 64 bit Ubuntu installed this should work perfectly, if you have a 32 bit OS installed the max RAM any program can use is 2GB

    – Wargog
    Jul 17 '15 at 19:20
















0














Via



java -Xmx3072m <your_class_name>


or



java -Xmx3072m -jar <your_jar_file>


or



JAVA_OPTS="-Xmx3G"
java "$JAVA_OPTS" -jar <your_jar_file>




Example



% java -Xmx80m -XshowSettings:all -jar HelloWorld.jar

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





all described in man java



-Xmxsize
Specifies the maximum size (in bytes) of the memory allocation pool
in bytes. This value must be a multiple of 1024 and greater than
2 MB. Append the letter k or K to indicate kilobytes, m or M to
indicate megabytes, g or G to indicate gigabytes. The default
value is chosen at runtime based on system configuration. For server
deployments, -Xms and -Xmx are often set to the same value. See the
section "Ergonomics" in Java SE HotSpot Virtual Machine Garbage
Collection Tuning Guide at
http://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/index.html.

The following examples show how to set the maximum allowed size of
allocated memory to 80 MB using various units:

-Xmx83886080
-Xmx81920k
-Xmx80m

The -Xmx option is equivalent to -XX:MaxHeapSize.






  • java JAVA_OPTS="-Xmx3g"



    Can't work, JAVA_OPTS= … isn't a valid parameter for java




  • JAVA_OPTS="-Xmx3g"



    Works, but useless in your case, because you define an environment variable without using it, eg:



    % JAVA_OPTS="-Xmx3g"
    % echo $JAVA_OPTS
    -Xmx3g







share|improve this answer





















  • 2





    As long as you have 64 bit Ubuntu installed this should work perfectly, if you have a 32 bit OS installed the max RAM any program can use is 2GB

    – Wargog
    Jul 17 '15 at 19:20














0












0








0







Via



java -Xmx3072m <your_class_name>


or



java -Xmx3072m -jar <your_jar_file>


or



JAVA_OPTS="-Xmx3G"
java "$JAVA_OPTS" -jar <your_jar_file>




Example



% java -Xmx80m -XshowSettings:all -jar HelloWorld.jar

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





all described in man java



-Xmxsize
Specifies the maximum size (in bytes) of the memory allocation pool
in bytes. This value must be a multiple of 1024 and greater than
2 MB. Append the letter k or K to indicate kilobytes, m or M to
indicate megabytes, g or G to indicate gigabytes. The default
value is chosen at runtime based on system configuration. For server
deployments, -Xms and -Xmx are often set to the same value. See the
section "Ergonomics" in Java SE HotSpot Virtual Machine Garbage
Collection Tuning Guide at
http://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/index.html.

The following examples show how to set the maximum allowed size of
allocated memory to 80 MB using various units:

-Xmx83886080
-Xmx81920k
-Xmx80m

The -Xmx option is equivalent to -XX:MaxHeapSize.






  • java JAVA_OPTS="-Xmx3g"



    Can't work, JAVA_OPTS= … isn't a valid parameter for java




  • JAVA_OPTS="-Xmx3g"



    Works, but useless in your case, because you define an environment variable without using it, eg:



    % JAVA_OPTS="-Xmx3g"
    % echo $JAVA_OPTS
    -Xmx3g







share|improve this answer















Via



java -Xmx3072m <your_class_name>


or



java -Xmx3072m -jar <your_jar_file>


or



JAVA_OPTS="-Xmx3G"
java "$JAVA_OPTS" -jar <your_jar_file>




Example



% java -Xmx80m -XshowSettings:all -jar HelloWorld.jar

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





all described in man java



-Xmxsize
Specifies the maximum size (in bytes) of the memory allocation pool
in bytes. This value must be a multiple of 1024 and greater than
2 MB. Append the letter k or K to indicate kilobytes, m or M to
indicate megabytes, g or G to indicate gigabytes. The default
value is chosen at runtime based on system configuration. For server
deployments, -Xms and -Xmx are often set to the same value. See the
section "Ergonomics" in Java SE HotSpot Virtual Machine Garbage
Collection Tuning Guide at
http://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/index.html.

The following examples show how to set the maximum allowed size of
allocated memory to 80 MB using various units:

-Xmx83886080
-Xmx81920k
-Xmx80m

The -Xmx option is equivalent to -XX:MaxHeapSize.






  • java JAVA_OPTS="-Xmx3g"



    Can't work, JAVA_OPTS= … isn't a valid parameter for java




  • JAVA_OPTS="-Xmx3g"



    Works, but useless in your case, because you define an environment variable without using it, eg:



    % JAVA_OPTS="-Xmx3g"
    % echo $JAVA_OPTS
    -Xmx3g








share|improve this answer














share|improve this answer



share|improve this answer








edited Jul 17 '15 at 19:05

























answered Jul 17 '15 at 18:48









A.B.A.B.

68.8k12169260




68.8k12169260








  • 2





    As long as you have 64 bit Ubuntu installed this should work perfectly, if you have a 32 bit OS installed the max RAM any program can use is 2GB

    – Wargog
    Jul 17 '15 at 19:20














  • 2





    As long as you have 64 bit Ubuntu installed this should work perfectly, if you have a 32 bit OS installed the max RAM any program can use is 2GB

    – Wargog
    Jul 17 '15 at 19:20








2




2





As long as you have 64 bit Ubuntu installed this should work perfectly, if you have a 32 bit OS installed the max RAM any program can use is 2GB

– Wargog
Jul 17 '15 at 19:20





As long as you have 64 bit Ubuntu installed this should work perfectly, if you have a 32 bit OS installed the max RAM any program can use is 2GB

– Wargog
Jul 17 '15 at 19:20


















draft saved

draft discarded




















































Thanks for contributing an answer to Ask Ubuntu!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f649627%2ftrouble-increasing-java-max-heap-size%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How did Captain America manage to do this?

迪纳利

南乌拉尔铁路局