< prev index next >

src/hotspot/share/gc/shared/genMemoryPools.cpp

Print this page




   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "gc/serial/defNewGeneration.hpp"
  27 #include "gc/shared/generation.hpp"
  28 #include "gc/shared/genMemoryPools.hpp"
  29 #include "gc/shared/space.hpp"



  30 
  31 ContiguousSpacePool::ContiguousSpacePool(ContiguousSpace* space,
  32                                          const char* name,
  33                                          size_t max_size,
  34                                          bool support_usage_threshold) :
  35   CollectedMemoryPool(name, space->capacity(), max_size,
  36                       support_usage_threshold), _space(space) {
  37 }
  38 
  39 size_t ContiguousSpacePool::used_in_bytes() {
  40   return space()->used();
  41 }
  42 
  43 MemoryUsage ContiguousSpacePool::get_memory_usage() {
  44   size_t maxSize   = (available_for_allocation() ? max_size() : 0);
  45   size_t used      = used_in_bytes();
  46   size_t committed = _space->capacity();
  47 
  48   return MemoryUsage(initial_size(), used, committed, maxSize);
  49 }
  50 


  51 SurvivorContiguousSpacePool::SurvivorContiguousSpacePool(DefNewGeneration* young_gen,
  52                                                          const char* name,
  53                                                          size_t max_size,
  54                                                          bool support_usage_threshold) :
  55   CollectedMemoryPool(name, young_gen->from()->capacity(), max_size,
  56                       support_usage_threshold), _young_gen(young_gen) {
  57 }
  58 
  59 size_t SurvivorContiguousSpacePool::used_in_bytes() {
  60   return _young_gen->from()->used();
  61 }
  62 
  63 size_t SurvivorContiguousSpacePool::committed_in_bytes() {
  64   return _young_gen->from()->capacity();
  65 }
  66 
  67 MemoryUsage SurvivorContiguousSpacePool::get_memory_usage() {
  68   size_t maxSize = (available_for_allocation() ? max_size() : 0);
  69   size_t used    = used_in_bytes();
  70   size_t committed = committed_in_bytes();
  71 
  72   return MemoryUsage(initial_size(), used, committed, maxSize);
  73 }


  74 
  75 GenerationPool::GenerationPool(Generation* gen,
  76                                const char* name,
  77                                bool support_usage_threshold) :
  78   CollectedMemoryPool(name, gen->capacity(), gen->max_capacity(),
  79                       support_usage_threshold), _gen(gen) {
  80 }
  81 
  82 size_t GenerationPool::used_in_bytes() {
  83   return _gen->used();
  84 }
  85 
  86 MemoryUsage GenerationPool::get_memory_usage() {
  87   size_t used      = used_in_bytes();
  88   size_t committed = _gen->capacity();
  89   size_t maxSize   = (available_for_allocation() ? max_size() : 0);
  90 
  91   return MemoryUsage(initial_size(), used, committed, maxSize);
  92 }


   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"

  26 #include "gc/shared/generation.hpp"
  27 #include "gc/shared/genMemoryPools.hpp"
  28 #include "gc/shared/space.hpp"
  29 #if INCLUDE_SERIALGC
  30 #include "gc/serial/defNewGeneration.hpp"
  31 #endif
  32 
  33 ContiguousSpacePool::ContiguousSpacePool(ContiguousSpace* space,
  34                                          const char* name,
  35                                          size_t max_size,
  36                                          bool support_usage_threshold) :
  37   CollectedMemoryPool(name, space->capacity(), max_size,
  38                       support_usage_threshold), _space(space) {
  39 }
  40 
  41 size_t ContiguousSpacePool::used_in_bytes() {
  42   return space()->used();
  43 }
  44 
  45 MemoryUsage ContiguousSpacePool::get_memory_usage() {
  46   size_t maxSize   = (available_for_allocation() ? max_size() : 0);
  47   size_t used      = used_in_bytes();
  48   size_t committed = _space->capacity();
  49 
  50   return MemoryUsage(initial_size(), used, committed, maxSize);
  51 }
  52 
  53 #if INCLUDE_SERIALGC
  54 
  55 SurvivorContiguousSpacePool::SurvivorContiguousSpacePool(DefNewGeneration* young_gen,
  56                                                          const char* name,
  57                                                          size_t max_size,
  58                                                          bool support_usage_threshold) :
  59   CollectedMemoryPool(name, young_gen->from()->capacity(), max_size,
  60                       support_usage_threshold), _young_gen(young_gen) {
  61 }
  62 
  63 size_t SurvivorContiguousSpacePool::used_in_bytes() {
  64   return _young_gen->from()->used();
  65 }
  66 
  67 size_t SurvivorContiguousSpacePool::committed_in_bytes() {
  68   return _young_gen->from()->capacity();
  69 }
  70 
  71 MemoryUsage SurvivorContiguousSpacePool::get_memory_usage() {
  72   size_t maxSize = (available_for_allocation() ? max_size() : 0);
  73   size_t used    = used_in_bytes();
  74   size_t committed = committed_in_bytes();
  75 
  76   return MemoryUsage(initial_size(), used, committed, maxSize);
  77 }
  78 
  79 #endif // INCLUDE_SERIALGC
  80 
  81 GenerationPool::GenerationPool(Generation* gen,
  82                                const char* name,
  83                                bool support_usage_threshold) :
  84   CollectedMemoryPool(name, gen->capacity(), gen->max_capacity(),
  85                       support_usage_threshold), _gen(gen) {
  86 }
  87 
  88 size_t GenerationPool::used_in_bytes() {
  89   return _gen->used();
  90 }
  91 
  92 MemoryUsage GenerationPool::get_memory_usage() {
  93   size_t used      = used_in_bytes();
  94   size_t committed = _gen->capacity();
  95   size_t maxSize   = (available_for_allocation() ? max_size() : 0);
  96 
  97   return MemoryUsage(initial_size(), used, committed, maxSize);
  98 }
< prev index next >