comparison src/share/vm/memory/permGen.cpp @ 1839:e41cd7fd68a6

6794422: Perm gen expansion policy for concurrent collectors Summary: Concurrent collectors should expand the perm gen without a full STW GC, but possibly by triggering a concurrent collection. Temporary band-aid for G1 where no concurrent collection is kicked off since the perm gen is not collected concurrently. Reviewed-by: johnc
author ysr
date Fri, 01 Oct 2010 16:12:54 -0700
parents c18cbe5936b8
children f95d63e2154a
comparison
equal deleted inserted replaced
1838:8f6f7587d292 1839:e41cd7fd68a6
1 /* 1 /*
2 * Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
23 */ 23 */
24 24
25 #include "incls/_precompiled.incl" 25 #include "incls/_precompiled.incl"
26 #include "incls/_permGen.cpp.incl" 26 #include "incls/_permGen.cpp.incl"
27 27
28 HeapWord* PermGen::request_expand_and_allocate(Generation* gen, size_t size,
29 GCCause::Cause prev_cause) {
30 if (gen->capacity() < _capacity_expansion_limit ||
31 prev_cause != GCCause::_no_gc || UseG1GC) { // last disjunct is a temporary hack for G1
32 return gen->expand_and_allocate(size, false);
33 }
34 // We have reached the limit of capacity expansion where
35 // we will not expand further until a GC is done; request denied.
36 return NULL;
37 }
38
28 HeapWord* PermGen::mem_allocate_in_gen(size_t size, Generation* gen) { 39 HeapWord* PermGen::mem_allocate_in_gen(size_t size, Generation* gen) {
29 GCCause::Cause next_cause = GCCause::_permanent_generation_full; 40 GCCause::Cause next_cause = GCCause::_permanent_generation_full;
30 GCCause::Cause prev_cause = GCCause::_no_gc; 41 GCCause::Cause prev_cause = GCCause::_no_gc;
31 unsigned int gc_count_before, full_gc_count_before; 42 unsigned int gc_count_before, full_gc_count_before;
32 HeapWord* obj; 43 HeapWord* obj;
35 { 46 {
36 MutexLocker ml(Heap_lock); 47 MutexLocker ml(Heap_lock);
37 if ((obj = gen->allocate(size, false)) != NULL) { 48 if ((obj = gen->allocate(size, false)) != NULL) {
38 return obj; 49 return obj;
39 } 50 }
40 if (gen->capacity() < _capacity_expansion_limit || 51 // Attempt to expand and allocate the requested space:
41 prev_cause != GCCause::_no_gc) { 52 // specific subtypes may use specific policy to either expand
42 obj = gen->expand_and_allocate(size, false); 53 // or not. The default policy (see above) is to expand until
43 } 54 // _capacity_expansion_limit, and no further unless a GC is done.
55 // Concurrent collectors may decide to kick off a concurrent
56 // collection under appropriate conditions.
57 obj = request_expand_and_allocate(gen, size, prev_cause);
58
44 if (obj != NULL || prev_cause == GCCause::_last_ditch_collection) { 59 if (obj != NULL || prev_cause == GCCause::_last_ditch_collection) {
45 return obj; 60 return obj;
46 } 61 }
47 if (GC_locker::is_active_and_needs_gc()) { 62 if (GC_locker::is_active_and_needs_gc()) {
48 // If this thread is not in a jni critical section, we stall 63 // If this thread is not in a jni critical section, we stall
117 desired_capacity = PermSize; 132 desired_capacity = PermSize;
118 } 133 }
119 if (_gen->capacity() > desired_capacity) { 134 if (_gen->capacity() > desired_capacity) {
120 _gen->shrink(_gen->capacity() - desired_capacity); 135 _gen->shrink(_gen->capacity() - desired_capacity);
121 } 136 }
122 _capacity_expansion_limit = _gen->capacity() + MaxPermHeapExpansion; 137 set_capacity_expansion_limit(_gen->capacity() + MaxPermHeapExpansion);
123 } 138 }