hotspot/test/gc/g1/TestGreyReclaimedHumongousObjects.java
author jprovino
Wed, 11 Nov 2015 23:47:42 +0000
changeset 33911 af2cff5bd523
parent 30254 224dcf3ebade
child 38083 2ffb46735fec
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
30182
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
     1
/*
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
     4
 *
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
     7
 * published by the Free Software Foundation.
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
     8
 *
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    13
 * accompanied this code).
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    14
 *
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    18
 *
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    21
 * questions.
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    22
 */
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    23
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    24
/*
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    25
 * @test TestGreyReclaimedHumongousObjects.java
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    26
 * @bug 8069367
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    27
 * @requires vm.gc == "G1" | vm.gc == "null"
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    28
 * @summary Test handling of marked but unscanned reclaimed humongous objects.
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    29
 * @key gc
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    30
 * @run main/othervm -XX:+UseG1GC -Xss32m -Xmx128m -XX:G1HeapRegionSize=1m
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    31
 *      -XX:+UnlockExperimentalVMOptions
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    32
 *          -XX:+G1EagerReclaimHumongousObjects
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    33
 *          -XX:+G1EagerReclaimHumongousObjectsWithStaleRefs
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    34
 *      TestGreyReclaimedHumongousObjects 1048576 90
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    35
 */
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    36
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    37
// This test spawns a bunch of threads, each of them rapidly
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    38
// allocating large objects and storing them into a circular buffer
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    39
// associated with the thread.  The circular buffer results in these
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    40
// objects becoming dead in fairly short order.
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    41
//
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    42
// The situation we're trying to provoke is
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    43
//
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    44
// (1) A humongous object H is marked and added to the mark stack.
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    45
//
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    46
// (2) An evacuation pause determines H is no longer live, and
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    47
// reclaims it.  This occurs before concurrent marking has gotten
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    48
// around to processing the mark stack entry for H.
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    49
//
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    50
// (3) Concurrent marking processes the mark stack entry for H.  The
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    51
// bug is that it would attempt to scan the now dead object.
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    52
//
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    53
// Unfortunately, this test is *very* sensitive to configuration.
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    54
// Among the parameters that affect whether / how often we'll get into
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    55
// the desired situation within a reasonable amount of time are:
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    56
//
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    57
// - THREAD_COUNT: The number of allocating threads.
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    58
//
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    59
// - OLD_COUNT: The number of objects each thread keeps.
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    60
//
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    61
// - MAX_MEMORY: The maximum heap size.
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    62
//
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    63
// - G1HeapRegionSize
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    64
//
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    65
// - The size of the objects being allocated.
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    66
//
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    67
// The parameter values specified here:
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    68
//
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    69
// - THREAD_COUNT = 12
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    70
// - OLD_COUNT == 4
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    71
// - MAX_MEMORY == 128m
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    72
// - G1HeapRegionSize = 1m
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    73
// - Object size = 1048576 (2 regions after header overhead and roundup)
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    74
//
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    75
// seems to work well at provoking the desired state fairly quickly.
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    76
// Even relatively small perturbations may change that.  The key
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    77
// factors seem to be keeping the heap mostly full of live objects but
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    78
// having them become dead fairly quickly.
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    79
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    80
import java.util.Date;
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    81
import java.util.concurrent.ExecutorService;
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    82
import java.util.concurrent.Executors;
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    83
import java.util.concurrent.ThreadFactory;
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    84
import java.util.concurrent.TimeUnit;
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    85
import com.sun.management.HotSpotDiagnosticMXBean;
30254
224dcf3ebade 8078144: many nightly tests failed due to NoSuchMethodError: sun.management.ManagementFactoryHelper.getDiagnosticMXBean
sjiang
parents: 30182
diff changeset
    86
import java.lang.management.ManagementFactory;
30182
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    87
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    88
public class TestGreyReclaimedHumongousObjects {
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    89
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    90
    static class NamedThreadFactory implements ThreadFactory {
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    91
       private int threadNum = 0;
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    92
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    93
       @Override
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    94
       public Thread newThread(Runnable r) {
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    95
         return new Thread(r, THREAD_NAME + (threadNum++));
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    96
       }
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    97
    }
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    98
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
    99
    static class Runner extends Thread {
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   100
        private final Date startDate = new Date();
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   101
        private final int obj_size;
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   102
        private final Object[] old_garbage;
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   103
        private int old_index = 0;
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   104
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   105
        public Runner(int obj_size) {
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   106
            this.obj_size = obj_size;
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   107
            old_garbage = new Object[OLD_COUNT];
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   108
        }
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   109
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   110
        private void allocate_garbage() {
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   111
            byte[] garbage = new byte[obj_size];
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   112
            old_garbage[Math.abs(++old_index % OLD_COUNT)] = garbage;
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   113
        }
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   114
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   115
        @Override
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   116
        public void run() {
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   117
            try {
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   118
                while (!isInterrupted()) {
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   119
                    allocate_garbage();
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   120
                    Thread.sleep(0); // Yield, to ensure interruptable.
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   121
                }
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   122
            } catch (InterruptedException e) {
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   123
                System.out.println("Aborted after "
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   124
                                   + (new Date().getTime() - startDate.getTime())
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   125
                                   + " ms");
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   126
                interrupt();
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   127
            }
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   128
        }
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   129
    }
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   130
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   131
    public static void main(String[] args) throws Exception {
30254
224dcf3ebade 8078144: many nightly tests failed due to NoSuchMethodError: sun.management.ManagementFactoryHelper.getDiagnosticMXBean
sjiang
parents: 30182
diff changeset
   132
        HotSpotDiagnosticMXBean diagnostic =
224dcf3ebade 8078144: many nightly tests failed due to NoSuchMethodError: sun.management.ManagementFactoryHelper.getDiagnosticMXBean
sjiang
parents: 30182
diff changeset
   133
                ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
30182
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   134
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   135
        System.out.println("Max memory= " + MAX_MEMORY + " bytes");
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   136
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   137
        int obj_size = 0;
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   138
        long seconds_to_run = 0;
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   139
        if (args.length != 2) {
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   140
            throw new RuntimeException("Object size argument must be supplied");
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   141
        } else {
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   142
            obj_size = Integer.parseInt(args[0]);
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   143
            seconds_to_run = Integer.parseInt(args[1]);
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   144
        }
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   145
        System.out.println("Objects size= " + obj_size + " bytes");
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   146
        System.out.println("Seconds to run=" + seconds_to_run);
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   147
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   148
        int region_size =
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   149
            Integer.parseInt(diagnostic.getVMOption("G1HeapRegionSize").getValue());
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   150
        if (obj_size < (region_size / 2)) {
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   151
            throw new RuntimeException("Object size " + obj_size +
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   152
                                       " is not humongous with region size " + region_size);
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   153
        }
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   154
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   155
        ExecutorService executor =
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   156
            Executors.newFixedThreadPool(THREAD_COUNT, new NamedThreadFactory());
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   157
        System.out.println("Starting " + THREAD_COUNT + " threads");
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   158
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   159
        for (int i = 0; i < THREAD_COUNT; i++) {
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   160
            executor.execute(new Runner(obj_size));
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   161
        }
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   162
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   163
        Thread.sleep(seconds_to_run * 1000);
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   164
        executor.shutdownNow();
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   165
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   166
        if (!executor.awaitTermination(10, TimeUnit.SECONDS)) {
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   167
            System.err.println("Thread pool did not terminate after 10 seconds after shutdown");
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   168
        }
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   169
    }
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   170
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   171
    private static final long MAX_MEMORY = Runtime.getRuntime().maxMemory();
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   172
    private static final int OLD_COUNT = 4;
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   173
    private static final int THREAD_COUNT = 12;
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   174
    private static final String THREAD_NAME = "TestGreyRH-";
1c980a880941 8069367: Eagerly reclaimed humongous objects left on mark stack
kbarrett
parents:
diff changeset
   175
}