Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8328168

Epsilon: Premature OOM when allocating object larger than uncommitted heap size

XMLWordPrintable

    • gc
    • b15
    • Verified

        When an object size meets the following three conditions, the allocation will fail unexpectedly.

        1. `object_size` > `uncommitted_size`
        2. `object_size` > `committed_but_unused_size`
        3. `object_size` < `unused_size` (`unused_size` equals `uncommitted_size + committed_but_unused_size`)


        The corresponding test case is shown below.

        ```
        package gc.epsilon;
        /**
         * @test TestEnoughUnusedSpace
         * @requires vm.gc.Epsilon
         * @summary Epsilon should allocates object successfully if it has enough space.
         * @run main/othervm -XX:InitialHeapSize=64M -Xmx128M -XX:+UnlockExperimentalVMOptions
         * -XX:+UseEpsilonGC gc.epsilon.TestEnoughUnusedSpace
         */

        public class TestEnoughUnusedSpace {
            public static void main(String[] args) {
                byte[] arr = new byte[90 * 1024 * 1024];
                System.out.println(arr.length);
            }
        }
        ```

              gli Guoxiong Li
              gli Guoxiong Li
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Created:
                Updated:
                Resolved: