--- old/src/share/vm/gc_implementation/g1/concurrentMark.cpp 2015-05-13 14:03:40.569365511 +0200 +++ new/src/share/vm/gc_implementation/g1/concurrentMark.cpp 2015-05-13 14:03:40.433360990 +0200 @@ -2665,7 +2665,6 @@ g1h->ensure_parsability(false); - StrongRootsScope srs; // this is remark, so we'll use up all active threads uint active_workers = g1h->workers()->active_workers(); if (active_workers == 0) { @@ -2679,13 +2678,17 @@ // constructor and pass values of the active workers // through the gang in the task. - CMRemarkTask remarkTask(this, active_workers); - // We will start all available threads, even if we decide that the - // active_workers will be fewer. The extra ones will just bail out - // immediately. - g1h->set_par_threads(active_workers); - g1h->workers()->run_task(&remarkTask); - g1h->set_par_threads(0); + { + StrongRootsScope srs(active_workers); + + CMRemarkTask remarkTask(this, active_workers); + // We will start all available threads, even if we decide that the + // active_workers will be fewer. The extra ones will just bail out + // immediately. + g1h->set_par_threads(active_workers); + g1h->workers()->run_task(&remarkTask); + g1h->set_par_threads(0); + } SATBMarkQueueSet& satb_mq_set = JavaThread::satb_mark_queue_set(); guarantee(has_overflown() ||