summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2022-03-22 15:14:22 +0100
committerSimon Rettberg2022-03-22 15:14:22 +0100
commit5204b8b5fc002b80e5e0adea78af66e91ae02e89 (patch)
treeb3b42822d85099b0fe03dbc80ef9c571295554d0
parent[FileTransfer] Log stack traces on error, some OOM handling (diff)
downloadmaster-sync-shared-5204b8b5fc002b80e5e0adea78af66e91ae02e89.tar.gz
master-sync-shared-5204b8b5fc002b80e5e0adea78af66e91ae02e89.tar.xz
master-sync-shared-5204b8b5fc002b80e5e0adea78af66e91ae02e89.zip
Print maximum VM memory in logHeader()
-rw-r--r--src/main/java/org/openslx/util/AppUtil.java12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/main/java/org/openslx/util/AppUtil.java b/src/main/java/org/openslx/util/AppUtil.java
index 22fa331..8733161 100644
--- a/src/main/java/org/openslx/util/AppUtil.java
+++ b/src/main/java/org/openslx/util/AppUtil.java
@@ -40,6 +40,8 @@ public class AppUtil
private static final String PROPERTY_JAVA_VERSION_VM = "java.vm.version";
private static final String PROPERTY_JAVA_VERSION_RUNTIME = "java.runtime.version";
+ private static final String PROPERTY_JAVA_MEMORY_LIMIT = "java.runtime.memory";
+
private static Attributes manifestAttributes = null;
private static String getManifestValue( final String entry )
@@ -127,6 +129,15 @@ public class AppUtil
public static void logHeader( final Logger logger, final String appName, final String appVersion )
{
+ final String mem;
+ long limit = Runtime.getRuntime().maxMemory() / ( 1024l * 1024 );
+ if ( limit > 99999999 ) {
+ mem = "-";
+ } else if ( limit >= 2048 ) {
+ mem = String.format( "%.1fG", limit / 1024f );
+ } else {
+ mem = limit + "M";
+ }
logger.info( "-------------------------------------------------------------------------------" );
logger.info( appName );
logger.info( "-------------------------------------------------------------------------------" );
@@ -143,6 +154,7 @@ public class AppUtil
logJavaProperty( logger, AppUtil.PROPERTY_JAVA_VERSION );
logJavaProperty( logger, AppUtil.PROPERTY_JAVA_VERSION_VM );
logJavaProperty( logger, AppUtil.PROPERTY_JAVA_VERSION_RUNTIME );
+ logProperty( logger, AppUtil.PROPERTY_JAVA_MEMORY_LIMIT, mem );
logger.info( "-------------------------------------------------------------------------------" );
}
}