Mercurial > hg > graal-jvmci-8
comparison src/share/vm/gc_implementation/shared/adaptiveSizePolicy.hpp @ 1387:0bfd3fb24150
6858496: Clear all SoftReferences before an out-of-memory due to GC overhead limit.
Summary: Ensure a full GC that clears SoftReferences before throwing an out-of-memory
Reviewed-by: ysr, jcoomes
author | jmasa |
---|---|
date | Tue, 13 Apr 2010 13:52:10 -0700 |
parents | a61af66fc99e |
children | c18cbe5936b8 |
comparison
equal
deleted
inserted
replaced
1361:6b73e879f1c2 | 1387:0bfd3fb24150 |
---|---|
1 /* | 1 /* |
2 * Copyright 2004-2006 Sun Microsystems, Inc. All Rights Reserved. | 2 * Copyright 2004-2010 Sun Microsystems, Inc. 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. |
25 // This class keeps statistical information and computes the | 25 // This class keeps statistical information and computes the |
26 // size of the heap. | 26 // size of the heap. |
27 | 27 |
28 // Forward decls | 28 // Forward decls |
29 class elapsedTimer; | 29 class elapsedTimer; |
30 class CollectorPolicy; | |
30 | 31 |
31 class AdaptiveSizePolicy : public CHeapObj { | 32 class AdaptiveSizePolicy : public CHeapObj { |
32 friend class GCAdaptivePolicyCounters; | 33 friend class GCAdaptivePolicyCounters; |
33 friend class PSGCAdaptivePolicyCounters; | 34 friend class PSGCAdaptivePolicyCounters; |
34 friend class CMSGCAdaptivePolicyCounters; | 35 friend class CMSGCAdaptivePolicyCounters; |
73 | 74 |
74 size_t _survivor_size; // calculated survivor size in bytes | 75 size_t _survivor_size; // calculated survivor size in bytes |
75 | 76 |
76 // This is a hint for the heap: we've detected that gc times | 77 // This is a hint for the heap: we've detected that gc times |
77 // are taking longer than GCTimeLimit allows. | 78 // are taking longer than GCTimeLimit allows. |
78 bool _gc_time_limit_exceeded; | 79 bool _gc_overhead_limit_exceeded; |
79 // Use for diagnostics only. If UseGCTimeLimit is false, | 80 // Use for diagnostics only. If UseGCOverheadLimit is false, |
80 // this variable is still set. | 81 // this variable is still set. |
81 bool _print_gc_time_limit_would_be_exceeded; | 82 bool _print_gc_overhead_limit_would_be_exceeded; |
82 // Count of consecutive GC that have exceeded the | 83 // Count of consecutive GC that have exceeded the |
83 // GC time limit criterion. | 84 // GC time limit criterion. |
84 uint _gc_time_limit_count; | 85 uint _gc_overhead_limit_count; |
86 // This flag signals that GCTimeLimit is being exceeded | |
87 // but may not have done so for the required number of consequetive | |
88 // collections. | |
85 | 89 |
86 // Minor collection timers used to determine both | 90 // Minor collection timers used to determine both |
87 // pause and interval times for collections. | 91 // pause and interval times for collections. |
88 static elapsedTimer _minor_timer; | 92 static elapsedTimer _minor_timer; |
89 | 93 |
404 // This is a hint for the heap: we've detected that gc times | 408 // This is a hint for the heap: we've detected that gc times |
405 // are taking longer than GCTimeLimit allows. | 409 // are taking longer than GCTimeLimit allows. |
406 // Most heaps will choose to throw an OutOfMemoryError when | 410 // Most heaps will choose to throw an OutOfMemoryError when |
407 // this occurs but it is up to the heap to request this information | 411 // this occurs but it is up to the heap to request this information |
408 // of the policy | 412 // of the policy |
409 bool gc_time_limit_exceeded() { | 413 bool gc_overhead_limit_exceeded() { |
410 return _gc_time_limit_exceeded; | 414 return _gc_overhead_limit_exceeded; |
411 } | 415 } |
412 void set_gc_time_limit_exceeded(bool v) { | 416 void set_gc_overhead_limit_exceeded(bool v) { |
413 _gc_time_limit_exceeded = v; | 417 _gc_overhead_limit_exceeded = v; |
414 } | 418 } |
415 bool print_gc_time_limit_would_be_exceeded() { | 419 |
416 return _print_gc_time_limit_would_be_exceeded; | 420 // Tests conditions indicate the GC overhead limit is being approached. |
417 } | 421 bool gc_overhead_limit_near() { |
418 void set_print_gc_time_limit_would_be_exceeded(bool v) { | 422 return gc_overhead_limit_count() >= |
419 _print_gc_time_limit_would_be_exceeded = v; | 423 (AdaptiveSizePolicyGCTimeLimitThreshold - 1); |
420 } | 424 } |
421 | 425 uint gc_overhead_limit_count() { return _gc_overhead_limit_count; } |
422 uint gc_time_limit_count() { return _gc_time_limit_count; } | 426 void reset_gc_overhead_limit_count() { _gc_overhead_limit_count = 0; } |
423 void reset_gc_time_limit_count() { _gc_time_limit_count = 0; } | 427 void inc_gc_overhead_limit_count() { _gc_overhead_limit_count++; } |
424 void inc_gc_time_limit_count() { _gc_time_limit_count++; } | |
425 // accessors for flags recording the decisions to resize the | 428 // accessors for flags recording the decisions to resize the |
426 // generations to meet the pause goal. | 429 // generations to meet the pause goal. |
427 | 430 |
428 int change_young_gen_for_min_pauses() const { | 431 int change_young_gen_for_min_pauses() const { |
429 return _change_young_gen_for_min_pauses; | 432 return _change_young_gen_for_min_pauses; |
433 } | 436 } |
434 void set_decrease_for_footprint(int v) { _decrease_for_footprint = v; } | 437 void set_decrease_for_footprint(int v) { _decrease_for_footprint = v; } |
435 int decrease_for_footprint() const { return _decrease_for_footprint; } | 438 int decrease_for_footprint() const { return _decrease_for_footprint; } |
436 int decide_at_full_gc() { return _decide_at_full_gc; } | 439 int decide_at_full_gc() { return _decide_at_full_gc; } |
437 void set_decide_at_full_gc(int v) { _decide_at_full_gc = v; } | 440 void set_decide_at_full_gc(int v) { _decide_at_full_gc = v; } |
441 | |
442 // Check the conditions for an out-of-memory due to excessive GC time. | |
443 // Set _gc_overhead_limit_exceeded if all the conditions have been met. | |
444 void check_gc_overhead_limit(size_t young_live, | |
445 size_t eden_live, | |
446 size_t max_old_gen_size, | |
447 size_t max_eden_size, | |
448 bool is_full_gc, | |
449 GCCause::Cause gc_cause, | |
450 CollectorPolicy* collector_policy); | |
438 | 451 |
439 // Printing support | 452 // Printing support |
440 virtual bool print_adaptive_size_policy_on(outputStream* st) const; | 453 virtual bool print_adaptive_size_policy_on(outputStream* st) const; |
441 bool print_adaptive_size_policy_on(outputStream* st, int | 454 bool print_adaptive_size_policy_on(outputStream* st, int |
442 tenuring_threshold) const; | 455 tenuring_threshold) const; |