comparison src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp @ 210:05712c37c828

6676016: ParallelOldGC leaks memory Summary: ensure that GCTask threads release resource and handle memory Reviewed-by: jmasa, chrisphi
author jcoomes
date Wed, 18 Jun 2008 18:36:47 -0700
parents 8bd1e4487c18
children 9c2ecc2ffb12 12eea04c8b06
comparison
equal deleted inserted replaced
209:4fab66d72627 210:05712c37c828
1002 heap->perm_gen()->verify_object_start_array(); 1002 heap->perm_gen()->verify_object_start_array();
1003 } 1003 }
1004 1004
1005 DEBUG_ONLY(mark_bitmap()->verify_clear();) 1005 DEBUG_ONLY(mark_bitmap()->verify_clear();)
1006 DEBUG_ONLY(summary_data().verify_clear();) 1006 DEBUG_ONLY(summary_data().verify_clear();)
1007
1008 // Have worker threads release resources the next time they run a task.
1009 gc_task_manager()->release_all_resources();
1007 } 1010 }
1008 1011
1009 void PSParallelCompact::post_compact() 1012 void PSParallelCompact::post_compact()
1010 { 1013 {
1011 TraceTime tm("post compact", print_phases(), true, gclog_or_tty); 1014 TraceTime tm("post compact", print_phases(), true, gclog_or_tty);
1947 1950
1948 TimeStamp marking_start; 1951 TimeStamp marking_start;
1949 TimeStamp compaction_start; 1952 TimeStamp compaction_start;
1950 TimeStamp collection_exit; 1953 TimeStamp collection_exit;
1951 1954
1952 // "serial_CM" is needed until the parallel implementation
1953 // of the move and update is done.
1954 ParCompactionManager* serial_CM = new ParCompactionManager();
1955 // Don't initialize more than once.
1956 // serial_CM->initialize(&summary_data(), mark_bitmap());
1957
1958 ParallelScavengeHeap* heap = gc_heap(); 1955 ParallelScavengeHeap* heap = gc_heap();
1959 GCCause::Cause gc_cause = heap->gc_cause(); 1956 GCCause::Cause gc_cause = heap->gc_cause();
1960 PSYoungGen* young_gen = heap->young_gen(); 1957 PSYoungGen* young_gen = heap->young_gen();
1961 PSOldGen* old_gen = heap->old_gen(); 1958 PSOldGen* old_gen = heap->old_gen();
1962 PSPermGen* perm_gen = heap->perm_gen(); 1959 PSPermGen* perm_gen = heap->perm_gen();
1967 // Make sure data structures are sane, make the heap parsable, and do other 1964 // Make sure data structures are sane, make the heap parsable, and do other
1968 // miscellaneous bookkeeping. 1965 // miscellaneous bookkeeping.
1969 PreGCValues pre_gc_values; 1966 PreGCValues pre_gc_values;
1970 pre_compact(&pre_gc_values); 1967 pre_compact(&pre_gc_values);
1971 1968
1969 // Get the compaction manager reserved for the VM thread.
1970 ParCompactionManager* const vmthread_cm =
1971 ParCompactionManager::manager_array(gc_task_manager()->workers());
1972
1972 // Place after pre_compact() where the number of invocations is incremented. 1973 // Place after pre_compact() where the number of invocations is incremented.
1973 AdaptiveSizePolicyOutput(size_policy, heap->total_collections()); 1974 AdaptiveSizePolicyOutput(size_policy, heap->total_collections());
1974 1975
1975 { 1976 {
1976 ResourceMark rm; 1977 ResourceMark rm;
2006 ref_processor()->enable_discovery(); 2007 ref_processor()->enable_discovery();
2007 2008
2008 bool marked_for_unloading = false; 2009 bool marked_for_unloading = false;
2009 2010
2010 marking_start.update(); 2011 marking_start.update();
2011 marking_phase(serial_CM, maximum_heap_compaction); 2012 marking_phase(vmthread_cm, maximum_heap_compaction);
2012 2013
2013 #ifndef PRODUCT 2014 #ifndef PRODUCT
2014 if (TraceParallelOldGCMarkingPhase) { 2015 if (TraceParallelOldGCMarkingPhase) {
2015 gclog_or_tty->print_cr("marking_phase: cas_tries %d cas_retries %d " 2016 gclog_or_tty->print_cr("marking_phase: cas_tries %d cas_retries %d "
2016 "cas_by_another %d", 2017 "cas_by_another %d",
2037 PSMarkSweep::mark_sweep_phase1(maximum_heap_compaction); 2038 PSMarkSweep::mark_sweep_phase1(maximum_heap_compaction);
2038 } 2039 }
2039 #endif 2040 #endif
2040 2041
2041 bool max_on_system_gc = UseMaximumCompactionOnSystemGC && is_system_gc; 2042 bool max_on_system_gc = UseMaximumCompactionOnSystemGC && is_system_gc;
2042 summary_phase(serial_CM, maximum_heap_compaction || max_on_system_gc); 2043 summary_phase(vmthread_cm, maximum_heap_compaction || max_on_system_gc);
2043 2044
2044 #ifdef ASSERT 2045 #ifdef ASSERT
2045 if (VerifyParallelOldWithMarkSweep && 2046 if (VerifyParallelOldWithMarkSweep &&
2046 (PSParallelCompact::total_invocations() % 2047 (PSParallelCompact::total_invocations() %
2047 VerifyParallelOldWithMarkSweepInterval) == 0) { 2048 VerifyParallelOldWithMarkSweepInterval) == 0) {
2065 VerifyParallelOldWithMarkSweepInterval) == 0) { 2066 VerifyParallelOldWithMarkSweepInterval) == 0) {
2066 // Do a separate verify phase so that the verify 2067 // Do a separate verify phase so that the verify
2067 // code can use the the forwarding pointers to 2068 // code can use the the forwarding pointers to
2068 // check the new pointer calculation. The restore_marks() 2069 // check the new pointer calculation. The restore_marks()
2069 // has to be done before the real compact. 2070 // has to be done before the real compact.
2070 serial_CM->set_action(ParCompactionManager::VerifyUpdate); 2071 vmthread_cm->set_action(ParCompactionManager::VerifyUpdate);
2071 compact_perm(serial_CM); 2072 compact_perm(vmthread_cm);
2072 compact_serial(serial_CM); 2073 compact_serial(vmthread_cm);
2073 serial_CM->set_action(ParCompactionManager::ResetObjects); 2074 vmthread_cm->set_action(ParCompactionManager::ResetObjects);
2074 compact_perm(serial_CM); 2075 compact_perm(vmthread_cm);
2075 compact_serial(serial_CM); 2076 compact_serial(vmthread_cm);
2076 serial_CM->set_action(ParCompactionManager::UpdateAndCopy); 2077 vmthread_cm->set_action(ParCompactionManager::UpdateAndCopy);
2077 2078
2078 // For debugging only 2079 // For debugging only
2079 PSMarkSweep::restore_marks(); 2080 PSMarkSweep::restore_marks();
2080 PSMarkSweep::deallocate_stacks(); 2081 PSMarkSweep::deallocate_stacks();
2081 } 2082 }
2082 #endif 2083 #endif
2083 2084
2084 compaction_start.update(); 2085 compaction_start.update();
2085 // Does the perm gen always have to be done serially because 2086 // Does the perm gen always have to be done serially because
2086 // klasses are used in the update of an object? 2087 // klasses are used in the update of an object?
2087 compact_perm(serial_CM); 2088 compact_perm(vmthread_cm);
2088 2089
2089 if (UseParallelOldGCCompacting) { 2090 if (UseParallelOldGCCompacting) {
2090 compact(); 2091 compact();
2091 } else { 2092 } else {
2092 compact_serial(serial_CM); 2093 compact_serial(vmthread_cm);
2093 } 2094 }
2094
2095 delete serial_CM;
2096 2095
2097 // Reset the mark bitmap, summary data, and do other bookkeeping. Must be 2096 // Reset the mark bitmap, summary data, and do other bookkeeping. Must be
2098 // done before resizing. 2097 // done before resizing.
2099 post_compact(); 2098 post_compact();
2100 2099