1 /* 2 * Copyright (c) 2017, 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 #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 }