1416 links
  • Animal
  • Home
  • Login
  • RSS Feed
  • ATOM Feed
  • Tag cloud
  • Picture wall
  • Daily
Links per page: 20 50 100
page 1 / 1
1 results tagged JVM x
  • Different Ways to Capture Java Heap Dumps | Baeldung

    Pour la troisième solution qui consiste à passer des options à la JVM :

    java -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=file_or_dir_path Main.java

    Note : Si c'est un répertoire qui est spécifié, alors le fichier sera nommé avec le numéro du pid. Par exemple java_pid22540.hprof .

    Et pour tester ces options, cette main simple génère une OutOfMemoryError :

    public static void main(String[] args) throws Exception {
    
            int dummyArraySize = 15;
            System.out.println("Max JVM memory: " + Runtime.getRuntime().maxMemory());
            long memoryConsumed = 0;
            try {
                long[] memoryAllocated = null;  
                for (int loop = 0; loop < Integer.MAX_VALUE; loop++) {
                    memoryAllocated = new long[dummyArraySize];
                    memoryAllocated[0] = 0;
                    memoryConsumed += dummyArraySize * Long.SIZE;
                    System.out.println("Memory Consumed till now: " + memoryConsumed);
                    dummyArraySize *= dummyArraySize * 2;
                    Thread.sleep(500);
                }
            } catch (OutOfMemoryError outofMemory) {
                System.out.println("Catching out of memory error");
                //Log the information,so that we can generate the statistics (latter on).
                throw outofMemory;
            }
        }
    Tue Dec 1 15:58:29 2020 * - permalink -
    QRCode
    - https://www.baeldung.com/java-heap-dump-capture
    Code Error HeapDump Java JVM OutOfMemoryError
Links per page: 20 50 100
page 1 / 1
Shaarli - The personal, minimalist, super-fast, database free, bookmarking service by the Shaarli community - Help/documentation