src/hotspot/share/memory/metaspaceShared.cpp
changeset 47679 4cfcb7be4984
parent 47599 0fb1d501c408
child 47765 b7c7428eaab9
equal deleted inserted replaced
47678:c84eeb55c55e 47679:4cfcb7be4984
   155   bool is_packed()  const { return _is_packed;   }
   155   bool is_packed()  const { return _is_packed;   }
   156   bool is_allocatable() const {
   156   bool is_allocatable() const {
   157     return !is_packed() && _base != NULL;
   157     return !is_packed() && _base != NULL;
   158   }
   158   }
   159 
   159 
   160   double perc(size_t used, size_t total) const {
       
   161     if (total == 0) {
       
   162       total = 1;
       
   163     }
       
   164     return used / double(total) * 100.0;
       
   165   }
       
   166 
       
   167   void print(size_t total_bytes) const {
   160   void print(size_t total_bytes) const {
   168     tty->print_cr("%-3s space: " SIZE_FORMAT_W(9) " [ %4.1f%% of total] out of " SIZE_FORMAT_W(9) " bytes [%5.1f%% used] at " INTPTR_FORMAT,
   161     tty->print_cr("%-3s space: " SIZE_FORMAT_W(9) " [ %4.1f%% of total] out of " SIZE_FORMAT_W(9) " bytes [%5.1f%% used] at " INTPTR_FORMAT,
   169                   _name, used(), perc(used(), total_bytes), reserved(), perc(used(), reserved()), p2i(_base));
   162                   _name, used(), percent_of(used(), total_bytes), reserved(), percent_of(used(), reserved()), p2i(_base));
   170   }
   163   }
   171   void print_out_of_space_msg(const char* failing_region, size_t needed_bytes) {
   164   void print_out_of_space_msg(const char* failing_region, size_t needed_bytes) {
   172     tty->print("[%-8s] " PTR_FORMAT " - " PTR_FORMAT " capacity =%9d, allocated =%9d",
   165     tty->print("[%-8s] " PTR_FORMAT " - " PTR_FORMAT " capacity =%9d, allocated =%9d",
   173                _name, p2i(_base), p2i(_top), int(_end - _base), int(_top - _base));
   166                _name, p2i(_base), p2i(_top), int(_end - _base), int(_top - _base));
   174     if (strcmp(_name, failing_region) == 0) {
   167     if (strcmp(_name, failing_region) == 0) {
   904     int rw_count = _counts[RW][type];
   897     int rw_count = _counts[RW][type];
   905     int rw_bytes = _bytes [RW][type];
   898     int rw_bytes = _bytes [RW][type];
   906     int count = ro_count + rw_count;
   899     int count = ro_count + rw_count;
   907     int bytes = ro_bytes + rw_bytes;
   900     int bytes = ro_bytes + rw_bytes;
   908 
   901 
   909     double ro_perc = 100.0 * double(ro_bytes) / double(ro_all);
   902     double ro_perc = percent_of(ro_bytes, ro_all);
   910     double rw_perc = 100.0 * double(rw_bytes) / double(rw_all);
   903     double rw_perc = percent_of(rw_bytes, rw_all);
   911     double perc    = 100.0 * double(bytes)    / double(ro_all + rw_all);
   904     double perc    = percent_of(bytes, ro_all + rw_all);
   912 
   905 
   913     info_stream.print_cr(fmt_stats, name,
   906     info_stream.print_cr(fmt_stats, name,
   914                          ro_count, ro_bytes, ro_perc,
   907                          ro_count, ro_bytes, ro_perc,
   915                          rw_count, rw_bytes, rw_perc,
   908                          rw_count, rw_bytes, rw_perc,
   916                          count, bytes, perc);
   909                          count, bytes, perc);
   922   }
   915   }
   923 
   916 
   924   int all_count = all_ro_count + all_rw_count;
   917   int all_count = all_ro_count + all_rw_count;
   925   int all_bytes = all_ro_bytes + all_rw_bytes;
   918   int all_bytes = all_ro_bytes + all_rw_bytes;
   926 
   919 
   927   double all_ro_perc = 100.0 * double(all_ro_bytes) / double(ro_all);
   920   double all_ro_perc = percent_of(all_ro_bytes, ro_all);
   928   double all_rw_perc = 100.0 * double(all_rw_bytes) / double(rw_all);
   921   double all_rw_perc = percent_of(all_rw_bytes, rw_all);
   929   double all_perc    = 100.0 * double(all_bytes)    / double(ro_all + rw_all);
   922   double all_perc    = percent_of(all_bytes, ro_all + rw_all);
   930 
   923 
   931   info_stream.print_cr("%s", sep);
   924   info_stream.print_cr("%s", sep);
   932   info_stream.print_cr(fmt_stats, "Total",
   925   info_stream.print_cr(fmt_stats, "Total",
   933                        all_ro_count, all_ro_bytes, all_ro_perc,
   926                        all_ro_count, all_ro_bytes, all_ro_perc,
   934                        all_rw_count, all_rw_bytes, all_rw_perc,
   927                        all_rw_count, all_rw_bytes, all_rw_perc,
  1425   const size_t total_bytes = _ro_region.used()  + _rw_region.used() +
  1418   const size_t total_bytes = _ro_region.used()  + _rw_region.used() +
  1426                              _mc_region.used()  + _md_region.used() +
  1419                              _mc_region.used()  + _md_region.used() +
  1427                              _od_region.used()  +
  1420                              _od_region.used()  +
  1428                              _total_string_region_size +
  1421                              _total_string_region_size +
  1429                              _total_open_archive_region_size;
  1422                              _total_open_archive_region_size;
  1430   const double total_u_perc = total_bytes / double(total_reserved) * 100.0;
  1423   const double total_u_perc = percent_of(total_bytes, total_reserved);
  1431 
  1424 
  1432   _mc_region.print(total_reserved);
  1425   _mc_region.print(total_reserved);
  1433   _rw_region.print(total_reserved);
  1426   _rw_region.print(total_reserved);
  1434   _ro_region.print(total_reserved);
  1427   _ro_region.print(total_reserved);
  1435   _md_region.print(total_reserved);
  1428   _md_region.print(total_reserved);