1 /*
   2  * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   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 class PSGenerationPool : public CollectedMemoryPool {
  26 private:
  27   PSOldGen* _gen;
  28 
  29 public:
  30   PSGenerationPool(PSOldGen* pool, const char* name, PoolType type, bool support_usage_threshold);
  31   PSGenerationPool(PSPermGen* pool, const char* name, PoolType type, bool support_usage_threshold);
  32 
  33   MemoryUsage get_memory_usage();
  34   size_t used_in_bytes()              { return _gen->used_in_bytes(); }
  35   size_t max_size() const             { return _gen->reserved().byte_size(); }
  36 };
  37 
  38 class EdenMutableSpacePool : public CollectedMemoryPool {
  39 private:
  40   PSYoungGen*   _gen;
  41   MutableSpace* _space;
  42 
  43 public:
  44   EdenMutableSpacePool(PSYoungGen* gen,
  45                        MutableSpace* space,
  46                        const char* name,
  47                        PoolType type,
  48                        bool support_usage_threshold);
  49 
  50   MutableSpace* space()                     { return _space; }
  51   MemoryUsage get_memory_usage();
  52   size_t used_in_bytes()                    { return space()->used_in_bytes(); }
  53   size_t max_size() const {
  54     // Eden's max_size = max_size of Young Gen - the current committed size of survivor spaces
  55     return _gen->max_size() - _gen->from_space()->capacity_in_bytes() - _gen->to_space()->capacity_in_bytes();
  56   }
  57 };
  58 
  59 class SurvivorMutableSpacePool : public CollectedMemoryPool {
  60 private:
  61   PSYoungGen*   _gen;
  62 
  63 public:
  64   SurvivorMutableSpacePool(PSYoungGen* gen,
  65                            const char* name,
  66                            PoolType type,
  67                            bool support_usage_threshold);
  68 
  69   MemoryUsage get_memory_usage();
  70 
  71   size_t used_in_bytes() {
  72     return _gen->from_space()->used_in_bytes();
  73   }
  74   size_t committed_in_bytes() {
  75     return _gen->from_space()->capacity_in_bytes();
  76   }
  77   size_t max_size() const {
  78     // Return current committed size of the from-space
  79     return _gen->from_space()->capacity_in_bytes();
  80   }
  81 };