1.1 --- a/src/share/vm/memory/permGen.cpp Thu Sep 30 12:15:13 2010 -0700 1.2 +++ b/src/share/vm/memory/permGen.cpp Fri Oct 01 16:12:54 2010 -0700 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -25,6 +25,17 @@ 1.11 #include "incls/_precompiled.incl" 1.12 #include "incls/_permGen.cpp.incl" 1.13 1.14 +HeapWord* PermGen::request_expand_and_allocate(Generation* gen, size_t size, 1.15 + GCCause::Cause prev_cause) { 1.16 + if (gen->capacity() < _capacity_expansion_limit || 1.17 + prev_cause != GCCause::_no_gc || UseG1GC) { // last disjunct is a temporary hack for G1 1.18 + return gen->expand_and_allocate(size, false); 1.19 + } 1.20 + // We have reached the limit of capacity expansion where 1.21 + // we will not expand further until a GC is done; request denied. 1.22 + return NULL; 1.23 +} 1.24 + 1.25 HeapWord* PermGen::mem_allocate_in_gen(size_t size, Generation* gen) { 1.26 GCCause::Cause next_cause = GCCause::_permanent_generation_full; 1.27 GCCause::Cause prev_cause = GCCause::_no_gc; 1.28 @@ -37,10 +48,14 @@ 1.29 if ((obj = gen->allocate(size, false)) != NULL) { 1.30 return obj; 1.31 } 1.32 - if (gen->capacity() < _capacity_expansion_limit || 1.33 - prev_cause != GCCause::_no_gc) { 1.34 - obj = gen->expand_and_allocate(size, false); 1.35 - } 1.36 + // Attempt to expand and allocate the requested space: 1.37 + // specific subtypes may use specific policy to either expand 1.38 + // or not. The default policy (see above) is to expand until 1.39 + // _capacity_expansion_limit, and no further unless a GC is done. 1.40 + // Concurrent collectors may decide to kick off a concurrent 1.41 + // collection under appropriate conditions. 1.42 + obj = request_expand_and_allocate(gen, size, prev_cause); 1.43 + 1.44 if (obj != NULL || prev_cause == GCCause::_last_ditch_collection) { 1.45 return obj; 1.46 } 1.47 @@ -119,5 +134,5 @@ 1.48 if (_gen->capacity() > desired_capacity) { 1.49 _gen->shrink(_gen->capacity() - desired_capacity); 1.50 } 1.51 - _capacity_expansion_limit = _gen->capacity() + MaxPermHeapExpansion; 1.52 + set_capacity_expansion_limit(_gen->capacity() + MaxPermHeapExpansion); 1.53 }