/* * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. * */ #include "gc/cms/cmsGCServicabilitySupport.hpp" #include "gc/cms/compactibleFreeListSpace.hpp" #include "gc/cms/concurrentMarkSweepGeneration.hpp" #include "gc/cms/parNewGeneration.hpp" #include "gc/shared/genCollectedHeap.hpp" #include "services/memoryManager.hpp" #include "services/memoryPool.hpp" class ParNewMemoryManager : public GCMemoryManager { private: public: ParNewMemoryManager() : GCMemoryManager() {} const char* name() { return "ParNew"; } }; class CMSMemoryManager : public GCMemoryManager { private: public: CMSMemoryManager() : GCMemoryManager() {} const char* name() { return "ConcurrentMarkSweep";} }; GCMemoryManager* CMSGCServicabilitySupport::create_minor_gc_manager() { return new ParNewMemoryManager(); } GCMemoryManager* CMSGCServicabilitySupport::create_major_gc_manager() { return new CMSMemoryManager(); } class CompactibleFreeListSpacePool : public CollectedMemoryPool { private: CompactibleFreeListSpace* _space; public: CompactibleFreeListSpacePool(CompactibleFreeListSpace* space, const char* name, PoolType type, size_t max_size, bool support_usage_threshold) : CollectedMemoryPool(name, type, space->capacity(), max_size, support_usage_threshold), _space(space) { } MemoryUsage get_memory_usage() { size_t maxSize = (available_for_allocation() ? max_size() : 0); size_t used = used_in_bytes(); size_t committed = _space->capacity(); return MemoryUsage(initial_size(), used, committed, maxSize); } size_t used_in_bytes() { return _space->used(); } }; void CMSGCServicabilitySupport::add_memory_pools(GrowableArray* pools_list, GCMemoryManager* minor_mgr, GCMemoryManager* major_mgr) { GenCollectedHeap* heap = GenCollectedHeap::heap(); ParNewGeneration* young_gen = (ParNewGeneration*) heap->young_gen(); ContiguousSpacePool* eden = new ContiguousSpacePool(young_gen->eden(), "Par Eden Space", MemoryPool::Heap, young_gen->max_eden_size(), false); SurvivorContiguousSpacePool* survivor = new SurvivorContiguousSpacePool(young_gen, "Par Survivor Space", MemoryPool::Heap, young_gen->max_survivor_size(), false); ConcurrentMarkSweepGeneration* cms = (ConcurrentMarkSweepGeneration*) heap->old_gen(); CompactibleFreeListSpacePool* old = new CompactibleFreeListSpacePool(cms->cmsSpace(), "CMS Old Gen", MemoryPool::Heap, cms->reserved().byte_size(), true); pools_list->append(eden); pools_list->append(survivor); pools_list->append(old); minor_mgr->add_pool(eden); major_mgr->add_pool(eden); minor_mgr->add_pool(survivor); major_mgr->add_pool(survivor); major_mgr->add_pool(old); }