test/gc/g1/TestHumongousShrinkHeap.java

Print this page
rev 6926 : 8056043: Heap does not shrink within the heap after JDK-8038423
Summary: Enable shrinking within the heap by removing some code added for JDK-8054818. Enable the test case that checks that again too.
Reviewed-by:


   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /**
  25  * @ignore 8041506, 8041946, 8042051
  26  * @test TestHumongousShrinkHeap
  27  * @bug 8036025
  28  * @summary Verify that heap shrinks after GC in the presence of fragmentation due to humongous objects
  29  * @library /testlibrary
  30  * @run main/othervm -XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=50 -XX:+UseG1GC -XX:G1HeapRegionSize=1M -verbose:gc TestHumongousShrinkHeap
  31  */
  32 
  33 import java.lang.management.ManagementFactory;
  34 import java.lang.management.MemoryUsage;
  35 import java.util.ArrayList;
  36 import java.util.List;
  37 import sun.management.ManagementFactoryHelper;
  38 import static com.oracle.java.testlibrary.Asserts.*;
  39 
  40 public class TestHumongousShrinkHeap {
  41 
  42     public static final String MIN_FREE_RATIO_FLAG_NAME = "MinHeapFreeRatio";
  43     public static final String MAX_FREE_RATIO_FLAG_NAME = "MaxHeapFreeRatio";
  44 
  45     private static final ArrayList<ArrayList<byte[]>> garbage = new ArrayList<>();
  46     private static final int PAGE_SIZE = 1024 * 1024; // 1M
  47     private static final int PAGES_NUM = 5;




   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /**

  25  * @test TestHumongousShrinkHeap
  26  * @bug 8036025 8056043
  27  * @summary Verify that heap shrinks after GC in the presence of fragmentation due to humongous objects
  28  * @library /testlibrary
  29  * @run main/othervm -XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=50 -XX:+UseG1GC -XX:G1HeapRegionSize=1M -verbose:gc TestHumongousShrinkHeap
  30  */
  31 
  32 import java.lang.management.ManagementFactory;
  33 import java.lang.management.MemoryUsage;
  34 import java.util.ArrayList;
  35 import java.util.List;
  36 import sun.management.ManagementFactoryHelper;
  37 import static com.oracle.java.testlibrary.Asserts.*;
  38 
  39 public class TestHumongousShrinkHeap {
  40 
  41     public static final String MIN_FREE_RATIO_FLAG_NAME = "MinHeapFreeRatio";
  42     public static final String MAX_FREE_RATIO_FLAG_NAME = "MaxHeapFreeRatio";
  43 
  44     private static final ArrayList<ArrayList<byte[]>> garbage = new ArrayList<>();
  45     private static final int PAGE_SIZE = 1024 * 1024; // 1M
  46     private static final int PAGES_NUM = 5;