flink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ches...@apache.org
Subject flink git commit: [hotfix] Reuse getMaxJvmHeapMemory() in EnvironmentInformation#getSizeOfFreeHeapMemory()
Date Wed, 13 Jul 2016 12:10:58 GMT
Repository: flink
Updated Branches:
  refs/heads/master e9f576ce2 -> 21d6a2928


[hotfix] Reuse getMaxJvmHeapMemory() in EnvironmentInformation#getSizeOfFreeHeapMemory()

This closes #2235


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/21d6a292
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/21d6a292
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/21d6a292

Branch: refs/heads/master
Commit: 21d6a292844521c6f2665a9f5b0f2867659afe5e
Parents: e9f576c
Author: Stefan Richter <s.richter@data-artisans.com>
Authored: Wed Jul 13 10:23:17 2016 +0200
Committer: zentol <chesnay@apache.org>
Committed: Wed Jul 13 14:10:26 2016 +0200

----------------------------------------------------------------------
 .../runtime/util/EnvironmentInformation.java      | 18 +-----------------
 1 file changed, 1 insertion(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/21d6a292/flink-runtime/src/main/java/org/apache/flink/runtime/util/EnvironmentInformation.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/util/EnvironmentInformation.java
b/flink-runtime/src/main/java/org/apache/flink/runtime/util/EnvironmentInformation.java
index 3b75b9f..a10522d 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/util/EnvironmentInformation.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/util/EnvironmentInformation.java
@@ -160,23 +160,7 @@ public class EnvironmentInformation {
 	 */
 	public static long getSizeOfFreeHeapMemory() {
 		Runtime r = Runtime.getRuntime();
-		long maxMemory = r.maxMemory();
-
-		if (maxMemory == Long.MAX_VALUE) {
-			// amount of free memory unknown
-			try {
-				// workaround for Oracle JDK
-				OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean();
-				Class<?> clazz = Class.forName("com.sun.management.OperatingSystemMXBean");
-				Method method = clazz.getMethod("getTotalPhysicalMemorySize");
-				maxMemory = (Long) method.invoke(operatingSystemMXBean) / 4;
-			} catch (Throwable e) {
-				throw new RuntimeException("Could not determine the amount of free memory.\n" +
-						"Please set the maximum memory for the JVM, e.g. -Xmx512M for 512 megabytes.");
-			}
-		}
-
-		return maxMemory - r.totalMemory() + r.freeMemory();
+		return getMaxJvmHeapMemory() - r.totalMemory() + r.freeMemory();
 	}
 
 	/**


Mime
View raw message