4

Is it possible to allow Java applications to collectively use x% of my RAM?

the8472
  • 40,999
  • 5
  • 70
  • 122
Adil Malik
  • 6,279
  • 7
  • 48
  • 77
  • 4
    You could write a wrapper script that calculates the total amount of memory and assign a share to each Java process started by it. –  May 02 '15 at 15:14
  • What is the operating system? – Michael Jaros May 02 '15 at 15:15
  • 1
    Because you only can specify the amount of available RAM only during invoking JVM, the application itself cannot reconfigure. But you could write the application that calculates appropriate amount of RAM, and then calls your main application with xmx argument for jvm . – pnadczuk May 02 '15 at 15:34
  • 1
    @MichaelJaros OS is Win 7 – Adil Malik May 02 '15 at 17:05

1 Answers1

1

If you know your RAM when you run your Java program then simply use -xmx and define how much total memory to use. Xmx is start command parameter and can't be changed dynamically. So, if you want to change it on the fly then you have to calculate it and restart your program with new parameters. Here is good example.

Community
  • 1
  • 1
Alex
  • 4,457
  • 2
  • 20
  • 59