1 /*
2 * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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 *
366 }
367
368 return success;
369 }
370
371
372 void DefNewGeneration::compute_new_size() {
373 // This is called after a gc that includes the following generation
374 // (which is required to exist.) So from-space will normally be empty.
375 // Note that we check both spaces, since if scavenge failed they revert roles.
376 // If not we bail out (otherwise we would have to relocate the objects)
377 if (!from()->is_empty() || !to()->is_empty()) {
378 return;
379 }
380
381 int next_level = level() + 1;
382 GenCollectedHeap* gch = GenCollectedHeap::heap();
383 assert(next_level < gch->_n_gens,
384 "DefNewGeneration cannot be an oldest gen");
385
386 Generation* next_gen = gch->_gens[next_level];
387 size_t old_size = next_gen->capacity();
388 size_t new_size_before = _virtual_space.committed_size();
389 size_t min_new_size = spec()->init_size();
390 size_t max_new_size = reserved().byte_size();
391 assert(min_new_size <= new_size_before &&
392 new_size_before <= max_new_size,
393 "just checking");
394 // All space sizes must be multiples of Generation::GenGrain.
395 size_t alignment = Generation::GenGrain;
396
397 // Compute desired new generation size based on NewRatio and
398 // NewSizeThreadIncrease
399 size_t desired_new_size = old_size/NewRatio;
400 int threads_count = Threads::number_of_non_daemon_threads();
401 size_t thread_increase_size = threads_count * NewSizeThreadIncrease;
402 desired_new_size = align_size_up(desired_new_size + thread_increase_size, alignment);
403
404 // Adjust new generation size
405 desired_new_size = MAX2(MIN2(desired_new_size, max_new_size), min_new_size);
406 assert(desired_new_size <= max_new_size, "just checking");
|
1 /*
2 * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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 *
366 }
367
368 return success;
369 }
370
371
372 void DefNewGeneration::compute_new_size() {
373 // This is called after a gc that includes the following generation
374 // (which is required to exist.) So from-space will normally be empty.
375 // Note that we check both spaces, since if scavenge failed they revert roles.
376 // If not we bail out (otherwise we would have to relocate the objects)
377 if (!from()->is_empty() || !to()->is_empty()) {
378 return;
379 }
380
381 int next_level = level() + 1;
382 GenCollectedHeap* gch = GenCollectedHeap::heap();
383 assert(next_level < gch->_n_gens,
384 "DefNewGeneration cannot be an oldest gen");
385
386 Generation* next_gen = gch->get_gen(next_level);
387 size_t old_size = next_gen->capacity();
388 size_t new_size_before = _virtual_space.committed_size();
389 size_t min_new_size = spec()->init_size();
390 size_t max_new_size = reserved().byte_size();
391 assert(min_new_size <= new_size_before &&
392 new_size_before <= max_new_size,
393 "just checking");
394 // All space sizes must be multiples of Generation::GenGrain.
395 size_t alignment = Generation::GenGrain;
396
397 // Compute desired new generation size based on NewRatio and
398 // NewSizeThreadIncrease
399 size_t desired_new_size = old_size/NewRatio;
400 int threads_count = Threads::number_of_non_daemon_threads();
401 size_t thread_increase_size = threads_count * NewSizeThreadIncrease;
402 desired_new_size = align_size_up(desired_new_size + thread_increase_size, alignment);
403
404 // Adjust new generation size
405 desired_new_size = MAX2(MIN2(desired_new_size, max_new_size), min_new_size);
406 assert(desired_new_size <= max_new_size, "just checking");
|