[jira] [Commented] (KARAF-2688) Karaf info - Add memory details about perm gen pool
[ https://issues.apache.org/jira/browse/KARAF-2688?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16368450#comment-16368450 ] ASF GitHub Bot commented on KARAF-2688: --- jbonofre closed pull request #452: [KARAF-2688] Adding information about memory pools. URL: https://github.com/apache/karaf/pull/452 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/InfoAction.java b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/InfoAction.java index 3311bd9720..22dea86509 100644 --- a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/InfoAction.java +++ b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/InfoAction.java @@ -20,6 +20,9 @@ import java.lang.management.GarbageCollectorMXBean; import java.lang.management.ManagementFactory; import java.lang.management.MemoryMXBean; +import java.lang.management.MemoryPoolMXBean; +import java.lang.management.MemoryType; +import java.lang.management.MemoryUsage; import java.lang.management.OperatingSystemMXBean; import java.lang.management.RuntimeMXBean; import java.lang.management.ThreadMXBean; @@ -40,6 +43,7 @@ import org.apache.karaf.shell.commands.info.InfoProvider; import org.apache.karaf.shell.api.action.Action; import org.apache.karaf.shell.api.action.Command; +import org.apache.karaf.shell.api.action.Option; import org.apache.karaf.shell.api.action.lifecycle.Service; import org.apache.karaf.shell.support.ansi.SimpleAnsi; import org.osgi.framework.Bundle; @@ -51,17 +55,26 @@ public class InfoAction implements Action { private NumberFormat fmtI = new DecimalFormat("###,###", new DecimalFormatSymbols(Locale.ENGLISH)); +private NumberFormat fmtDec = new DecimalFormat("###,###.##", new DecimalFormatSymbols(Locale.ENGLISH)); private NumberFormat fmtD = new DecimalFormat("###,##0.000", new DecimalFormatSymbols(Locale.ENGLISH)); +private OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean(); + +@Option(name="--memory-pools", aliases= {"-mp"}, description="Includes detailed information about memory pools") +protected boolean showMemoryPools; + //@Reference List infoProviders; +public InfoAction() { +fmtDec.setMinimumFractionDigits(2); +} + @Override public Object execute() throws Exception { int maxNameLen; RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean(); -OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean(); ThreadMXBean threads = ManagementFactory.getThreadMXBean(); MemoryMXBean mem = ManagementFactory.getMemoryMXBean(); ClassLoadingMXBean cl = ManagementFactory.getClassLoadingMXBean(); @@ -87,7 +100,16 @@ public Object execute() throws Exception { printValue("Pid", maxNameLen, getPid()); printValue("Uptime", maxNameLen, printDuration(runtime.getUptime())); try { -printValue("Process CPU time", maxNameLen, printDuration(getSunOsValueAsLong(os, "getProcessCpuTime") / 100)); +Class< ? > sunOS = Class.forName("com.sun.management.OperatingSystemMXBean"); +printValue("Process CPU time", maxNameLen, printDuration(getValueAsLong(sunOS, "getProcessCpuTime") / 100)); +printValue("Process CPU load", maxNameLen, fmtDec.format(getValueAsDouble(sunOS, "getProcessCpuLoad"))); +printValue("System CPU load", maxNameLen, fmtDec.format(getValueAsDouble(sunOS, "getSystemCpuLoad"))); +} catch (Throwable t) { +} +try { +Class unixOS = Class.forName("com.sun.management.UnixOperatingSystemMXBean"); +printValue("Open file descriptors", maxNameLen, printLong(getValueAsLong(unixOS, "getOpenFileDescriptorCount"))); +printValue("Max file descriptors", maxNameLen, printLong(getValueAsLong(unixOS, "getMaxFileDescriptorCount"))); } catch (Throwable t) { } printValue("Total compile time", maxNameLen, printDuration(ManagementFactory.getCompilationMXBean().getTotalCompilationTime())); @@ -108,6 +130,45 @@ public Object execute() throws Exception { printValue("Garbage collector", maxNameLen, val); } +if (showMemoryPools) { +List memoryPools = ManagementFactory.getMemoryPoolMXBeans(); +System.out.println("Memory Pools"); +printValue("Total Memory Pools", maxNameLen, printLong(memoryPools.size())); +String spaces4 = " "; +for (MemoryPoolMXBean pool : memoryPools) +{ +String na
[jira] [Commented] (KARAF-2688) Karaf info - Add memory details about perm gen pool
[ https://issues.apache.org/jira/browse/KARAF-2688?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16361992#comment-16361992 ] ASF GitHub Bot commented on KARAF-2688: --- MrEasy opened a new pull request #452: [KARAF-2688] Adding information about memory pools. URL: https://github.com/apache/karaf/pull/452 This commit not only adds info on perm-gen as requested in KARAF-2688, but generally prints onfo on the memory-pools, which might include perm-gen for the appropriate VM or e.g. MetaSpace for Oracle-Java8. Since info is quite detailed, I made its output optional via **--memory-pools**. Also added file descriptor info when on Unix. Example output, running with Oracle-Java8 and G1-GC (unchanged, unrelated ouput omitted via (...)): ``` info --memory-pools Karaf (...) JVM (...) Process CPU load0.05 System CPU load 0.66 Open file descriptors 663 Max file descriptors1,048,576 Total compile time 1 minute Threads (...) Memory Current heap size 427,008 kbytes Maximum heap size 1,048,576 kbytes Committed heap size 589,824 kbytes Pending objects 0 Garbage collector Name = 'G1 Young Generation', Collections = 33, Time = 1.447 seconds Garbage collector Name = 'G1 Old Generation', Collections = 0, Time = 0.000 seconds Memory Pools Total Memory Pools 6 Pool (Non-heap memory) Code Cache Peak Usage init 2,555,904 used 38,015,040 committed: 38,338,560 max: 251,658,240 Current Usage init: 2,555,904 used: 37,968,576 committed: 38,338,560 max: 251,658,240 Pool (Non-heap memory) Metaspace Peak Usage init 0 used 96,152,744 committed: 110,964,736 max: 1,073,741,824 Current Usage init: 0 used: 96,152,744 committed: 110,964,736 max: 1,073,741,824 Pool (Non-heap memory) Compressed Class Space Peak Usage init 0 used 11,900,544 committed: 16,068,608 max: 1,073,741,824 Current Usage init: 0 used: 11,900,544 committed: 16,068,608 max: 1,073,741,824 Pool (Heap memory) G1 Eden Space Peak Usage init 27,262,976 used 357,564,416 committed: 378,535,936 max: -1 Current Usage init: 27,262,976 used: 284,164,096 committed: 378,535,936 max: -1 Pool (Heap memory) G1 Survivor Space Peak Usage init 0 used 46,137,344 committed: 46,137,344 max: -1 Current Usage init: 0 used: 2,097,152 committed: 2,097,152 max: -1 Pool (Heap memory) G1 Old Gen Peak Usage init 106,954,752 used 153,092,600 committed: 572,522,496 max: 1,073,741,824 Current Usage init: 106,954,752 used: 150,994,944 committed: 223,346,688 max: 1,073,741,824 Classes (...) Operating system (...) ``` This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Karaf info - Add memory details about perm gen pool > --- > > Key: KARAF-2688 > URL: https://issues.apache.org/jira/browse/KARAF-2688 > Project: Karaf > Issue Type: Improvement > Components: karaf-core, karaf-shell >Affects Versions: 2.3.3 >Reporter: Claus Ibsen >Assignee: Jean-Baptiste
[jira] [Commented] (KARAF-2688) Karaf info - Add memory details about perm gen pool
[ https://issues.apache.org/jira/browse/KARAF-2688?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14108117#comment-14108117 ] Achim Nierbeck commented on KARAF-2688: --- On JDK8 neither > Karaf info - Add memory details about perm gen pool > --- > > Key: KARAF-2688 > URL: https://issues.apache.org/jira/browse/KARAF-2688 > Project: Karaf > Issue Type: Improvement > Components: karaf-core, karaf-shell >Affects Versions: 2.3.3 >Reporter: Claus Ibsen >Assignee: Jean-Baptiste Onofré >Priority: Minor > Fix For: 4.0.0, 3.0.2, 2.4.1, 2.3.7 > > Attachments: Screen Shot 2014-01-16 at 3.05.16 PM.png > > > When running the info command you get some JVM details > For memory you get > {code} > Memory > Current heap size 90,407 kbytes > Maximum heap size 521,216 kbytes > Committed heap size 106,496 kbytes > {code} > It would be good to have the perm-gen pool as well. As if you are running out > of perm gen you are fucked. The GC cannot reclaim perm gen memory. -- This message was sent by Atlassian JIRA (v6.2#6252)
[jira] [Commented] (KARAF-2688) Karaf info - Add memory details about perm gen pool
[ https://issues.apache.org/jira/browse/KARAF-2688?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13873411#comment-13873411 ] Jean-Baptiste Onofré commented on KARAF-2688: - I gonna do it depending of the JVM (it doesn't make sense on IBM JDK). > Karaf info - Add memory details about perm gen pool > --- > > Key: KARAF-2688 > URL: https://issues.apache.org/jira/browse/KARAF-2688 > Project: Karaf > Issue Type: Improvement > Components: karaf-core, karaf-shell >Affects Versions: 2.3.3 >Reporter: Claus Ibsen >Assignee: Jean-Baptiste Onofré >Priority: Minor > Fix For: 2.4.0, 3.0.1, 2.3.4 > > Attachments: Screen Shot 2014-01-16 at 3.05.16 PM.png > > > When running the info command you get some JVM details > For memory you get > {code} > Memory > Current heap size 90,407 kbytes > Maximum heap size 521,216 kbytes > Committed heap size 106,496 kbytes > {code} > It would be good to have the perm-gen pool as well. As if you are running out > of perm gen you are fucked. The GC cannot reclaim perm gen memory. -- This message was sent by Atlassian JIRA (v6.1.5#6160)
[jira] [Commented] (KARAF-2688) Karaf info - Add memory details about perm gen pool
[ https://issues.apache.org/jira/browse/KARAF-2688?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13873410#comment-13873410 ] Jean-Baptiste Onofré commented on KARAF-2688: - +1 > Karaf info - Add memory details about perm gen pool > --- > > Key: KARAF-2688 > URL: https://issues.apache.org/jira/browse/KARAF-2688 > Project: Karaf > Issue Type: Improvement > Components: karaf-core, karaf-shell >Affects Versions: 2.3.3 >Reporter: Claus Ibsen >Assignee: Jean-Baptiste Onofré >Priority: Minor > Fix For: 2.4.0, 3.0.1, 2.3.4 > > Attachments: Screen Shot 2014-01-16 at 3.05.16 PM.png > > > When running the info command you get some JVM details > For memory you get > {code} > Memory > Current heap size 90,407 kbytes > Maximum heap size 521,216 kbytes > Committed heap size 106,496 kbytes > {code} > It would be good to have the perm-gen pool as well. As if you are running out > of perm gen you are fucked. The GC cannot reclaim perm gen memory. -- This message was sent by Atlassian JIRA (v6.1.5#6160)