# HG changeset patch # User rkennke # Date 1504605036 -7200 # Tue Sep 05 11:50:36 2017 +0200 # Node ID 22dc87358272cb4d69f3d6adb85d20d067c3f7b4 # Parent 88976a2207e0fcc0c662c7643bd09a25cc87205c Make sure we have at least one memory pool per memory manager (JMX). diff --git a/src/share/vm/services/memoryService.cpp b/src/share/vm/services/memoryService.cpp --- a/src/share/vm/services/memoryService.cpp +++ b/src/share/vm/services/memoryService.cpp @@ -205,8 +205,8 @@ _minor_gc_manager = MemoryManager::get_shenandoah_minor_memory_manager(); _managers_list->append(_major_gc_manager); _managers_list->append(_minor_gc_manager); - add_shenandoah_memory_pool(pgch, _minor_gc_manager, true); - add_shenandoah_memory_pool(pgch, _minor_gc_manager, false); + add_shenandoah_memory_pool(pgch, _major_gc_manager); + add_shenandoah_memory_pool(pgch, _minor_gc_manager); } #endif // INCLUDE_ALL_GCS @@ -409,16 +409,14 @@ } void MemoryService::add_shenandoah_memory_pool(ShenandoahHeap* pgc, - MemoryManager* mgr, bool global) { + MemoryManager* mgr) { ShenandoahMemoryPool* pool = new ShenandoahMemoryPool(pgc, "Shenandoah", MemoryPool::Heap, false /* support_usage_threshold */); mgr->add_pool(pool); - if (global) { - _pools_list->append(pool); - } + _pools_list->append(pool); } diff --git a/src/share/vm/services/memoryService.hpp b/src/share/vm/services/memoryService.hpp --- a/src/share/vm/services/memoryService.hpp +++ b/src/share/vm/services/memoryService.hpp @@ -95,8 +95,7 @@ MemoryManager* mgr); static void add_shenandoah_memory_pool(ShenandoahHeap* pgc, - MemoryManager* mgr, - bool global); + MemoryManager* mgr); static MemoryPool* add_space(ContiguousSpace* space, const char* name, diff --git a/test/gc/shenandoah/TestMemoryPools.java b/test/gc/shenandoah/TestMemoryPools.java new file mode 100644 --- /dev/null +++ b/test/gc/shenandoah/TestMemoryPools.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2017 Red Hat, Inc. and/or its affiliates. + * + * 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. + * + */ + +/** + * @test TestMemoryPools + * @key gc + * @summary Test JMX memory pools + * @modules java.base/jdk.internal.misc + * java.management + * @run main/othervm -XX:+UseShenandoahGC -Xmx1g -Xms1g TestMemoryPools + */ + + +import java.lang.management.*; +import java.util.*; + +public class TestMemoryPools { + + public static void main(String[] args) throws Exception { + List mms = ManagementFactory.getMemoryManagerMXBeans(); + if (mms == null) { + fail("getMemoryManagerMXBeans is null"); + } + if (mms.isEmpty()) { + fail("getMemoryManagerMXBeans is empty"); + } + for (MemoryManagerMXBean mmBean : mms) { + String[] names = mmBean.getMemoryPoolNames(); + if (names == null) { + fail("getMemoryPoolNames() is null"); + } + if (names.length == 0) { + throw new RuntimeException("getMemoryPoolNames() is empty"); + } + for (String name : names) { + if (name == null) { + fail("pool name is null"); + } + if (name.length() == 0) { + fail("pool name is empty"); + } + } + } + } + + private static void fail(String msg) { + throw new RuntimeException(msg); + } +}