Quote Originariamente inviata da fermat Visualizza il messaggio
dedicargli il 100% della ram non mi sembra una buona cosa.
devi sempre considerare il sistema operativo e tutte le applicazioni / servizi che girano di default.

detto ciò, usare una delle opzioni del link postato?

-XX:MinHeapFreeRatio impostato a 100 dovrebbe andare.
Perché non funziona, questo è quello che ottengo:

Unrecognized VM option 'MinHeapFreeRatio50'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Ho anche provato il vecchio codice:

-Xms512m -Xmx8192m

ma non funziona, Linux riempe al massimo 4GB di ram, non di più.

Questo è il codice:

codice:
//-Xms512m -Xmx8192m

package prova;

import java.util.Formatter;

public class Esempio {
    public static void main(String[] args) {
        int variabile_globale = 100;
        int variabile_globale2 = 100000;
        String A[][] = new String[variabile_globale][variabile_globale];
        String valore = "0123456789";
        for (int i = 0; i < variabile_globale2; i++) {
            valore = valore + "0123456789";
        }
        for (int i = 0; i < A.length; i++) {
            for (int j = 0; j < A[0].length; j++) {
                A[i][j] = valore;
            }
        }

        double maxHeapSize = Runtime.getRuntime().maxMemory()
                * Math.pow(2, -30);
        double freeHeapSize = Runtime.getRuntime().freeMemory()
                * Math.pow(2, -30);
        double totalHeapSize = Runtime.getRuntime().totalMemory()
                * Math.pow(2, -30);
        Formatter fmt1 = new Formatter();
        Formatter fmt2 = new Formatter();
        Formatter fmt3 = new Formatter();
        System.out.println("Max Heap Size = "
                + fmt1.format("%.2f", maxHeapSize) + " GB");
        System.out.println("Free Heap Size = "
                + fmt2.format("%.2f", freeHeapSize) + " GB");
        System.out.println("Total Heap Size = "
                + fmt3.format("%.2f", totalHeapSize) + " GB");
        System.out.println("Operazione terminata");
        fmt1.close();
        fmt2.close();
        fmt3.close();
    }
}
Questo l'uotput quando uso -Xms512m -Xmx16000m:

Max Heap Size = 13,89 GB
Free Heap Size = 1,12 GB
Total Heap Size = 2,37 GB
Operazione terminata
Io voglio vedere dal monitor di ubuntu la ram salire fino al massimo valore possibile.