Java Code Examples for java.lang.management.MemoryMXBean#setVerbose()
The following examples show how to use
java.lang.management.MemoryMXBean#setVerbose() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Main.java From pravega with Apache License 2.0 | 6 votes |
@VisibleForTesting static void onShutdown(ControllerServiceMain controllerServiceMain) { MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean(); memoryMXBean.setVerbose(true); log.info("Shutdown hook memory usage dump: Heap memory usage: {}, non heap memory usage {}", memoryMXBean.getHeapMemoryUsage(), memoryMXBean.getNonHeapMemoryUsage()); log.info("Controller service shutting down"); try { controllerServiceMain.stopAsync(); controllerServiceMain.awaitTerminated(); } finally { if (Config.DUMP_STACK_ON_SHUTDOWN) { Thread.getAllStackTraces().forEach((key, value) -> log.info("Shutdown Hook Thread dump: Thread {} stackTrace: {} ", key.getName(), value)); } } }
Example 2
Source File: PlatformMBeanResourceUnitTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testMemoryMXBean() throws IOException { DescribedResource describedResource = basicResourceTest("memory", null); MemoryMXBean mbean = ManagementFactory.getMemoryMXBean(); boolean verbose = describedResource.resource.get("verbose").asBoolean(); Assert.assertEquals(mbean.isVerbose(), verbose); ModelNode op = getOperation("write-attribute", "memory", null); op.get("name").set("verbose"); op.get("value").set(!verbose); executeOp(op, false); Assert.assertEquals(mbean.isVerbose(), !verbose); // Restore mbean.setVerbose(verbose); op = getOperation("gc", "memory", null); Assert.assertFalse(executeOp(op, false).isDefined()); }