0

I know is possible to increase Java heap before calling the program, like this:

java -Xmx6g myprogram

But it's possible do the same thing with a Java command? Example:

public class AddTwoIntegers {

    public static void main(String[] args) {
        System.IncreaseMyHeap

        int first = 10;
        int second = 20;

        System.out.println("Enter two numbers: " + first + " " + second);
        int sum = first + second;

        System.out.println("The sum is: " + sum);
    }
}
Nifriz
  • 1,033
  • 1
  • 10
  • 21
  • 1
    Does this answer your question? [programmatically setting max java heap size](https://stackoverflow.com/questions/4789280/programmatically-setting-max-java-heap-size) – Carlo Corradini Sep 08 '20 at 14:45
  • 1
    Does this answer your question? [How there is no affect of setting memory through System.setProperty?](https://stackoverflow.com/questions/13604681/how-there-is-no-affect-of-setting-memory-through-system-setproperty) – Doga Oruc Sep 08 '20 at 14:45

0 Answers0