@@ -1497,6 +1497,8 @@ size_t ObjectSynchronizer::deflate_idle_monitors(ObjectMonitorsHashtable* table)
1497
1497
1498
1498
// Deflate some idle ObjectMonitors.
1499
1499
size_t deflated_count = deflate_monitor_list (current, ls, &timer, table);
1500
+ size_t unlinked_count = 0 ;
1501
+ size_t deleted_count = 0 ;
1500
1502
if (deflated_count > 0 || is_final_audit ()) {
1501
1503
// There are ObjectMonitors that have been deflated or this is the
1502
1504
// final audit and all the remaining ObjectMonitors have been
@@ -1506,8 +1508,7 @@ size_t ObjectSynchronizer::deflate_idle_monitors(ObjectMonitorsHashtable* table)
1506
1508
// Unlink deflated ObjectMonitors from the in-use list.
1507
1509
ResourceMark rm;
1508
1510
GrowableArray<ObjectMonitor*> delete_list ((int )deflated_count);
1509
- size_t unlinked_count = _in_use_list.unlink_deflated (current, ls, &timer,
1510
- &delete_list);
1511
+ unlinked_count = _in_use_list.unlink_deflated (current, ls, &timer, &delete_list);
1511
1512
if (current->is_Java_thread ()) {
1512
1513
if (ls != NULL ) {
1513
1514
timer.stop ();
@@ -1533,7 +1534,6 @@ size_t ObjectSynchronizer::deflate_idle_monitors(ObjectMonitorsHashtable* table)
1533
1534
1534
1535
// After the handshake, safely free the ObjectMonitors that were
1535
1536
// deflated in this cycle.
1536
- size_t deleted_count = 0 ;
1537
1537
for (ObjectMonitor* monitor: delete_list) {
1538
1538
delete monitor;
1539
1539
deleted_count++;
@@ -1544,13 +1544,14 @@ size_t ObjectSynchronizer::deflate_idle_monitors(ObjectMonitorsHashtable* table)
1544
1544
deleted_count, ls, &timer);
1545
1545
}
1546
1546
}
1547
+ assert (unlinked_count == deleted_count, " must be" );
1547
1548
}
1548
1549
1549
1550
if (ls != NULL ) {
1550
1551
timer.stop ();
1551
- if (deflated_count != 0 || log_is_enabled (Debug, monitorinflation)) {
1552
- ls->print_cr (" deflated " SIZE_FORMAT " monitors in %3.7f secs" ,
1553
- deflated_count, timer.seconds ());
1552
+ if (deflated_count != 0 || unlinked_count != 0 || log_is_enabled (Debug, monitorinflation)) {
1553
+ ls->print_cr (" deflated_count= " SIZE_FORMAT " , {unlinked,deleted}_count= " SIZE_FORMAT " monitors in %3.7f secs" ,
1554
+ deflated_count, unlinked_count, timer.seconds ());
1554
1555
}
1555
1556
ls->print_cr (" end deflating: in_use_list stats: ceiling=" SIZE_FORMAT " , count=" SIZE_FORMAT " , max=" SIZE_FORMAT,
1556
1557
in_use_list_ceiling (), _in_use_list.count (), _in_use_list.max ());
@@ -1659,17 +1660,18 @@ void ObjectSynchronizer::do_final_audit_and_print_stats() {
1659
1660
return ;
1660
1661
}
1661
1662
set_is_final_audit ();
1663
+ log_info (monitorinflation)(" Starting the final audit." );
1662
1664
1663
1665
if (log_is_enabled (Info, monitorinflation)) {
1664
- // Do a deflation in order to reduce the in-use monitor population
1666
+ // Do deflations in order to reduce the in-use monitor population
1665
1667
// that is reported by ObjectSynchronizer::log_in_use_monitor_details()
1666
1668
// which is called by ObjectSynchronizer::audit_and_print_stats().
1667
- while (ObjectSynchronizer:: deflate_idle_monitors (/* ObjectMonitorsHashtable is not needed here */ nullptr ) >= ( size_t )MonitorDeflationMax ) {
1669
+ while (deflate_idle_monitors (/* ObjectMonitorsHashtable is not needed here */ nullptr ) > 0 ) {
1668
1670
; // empty
1669
1671
}
1670
1672
// The other audit_and_print_stats() call is done at the Debug
1671
1673
// level at a safepoint in SafepointSynchronize::do_cleanup_tasks.
1672
- ObjectSynchronizer:: audit_and_print_stats (true /* on_exit */ );
1674
+ audit_and_print_stats (true /* on_exit */ );
1673
1675
}
1674
1676
}
1675
1677
0 commit comments