You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by ch...@apache.org on 2016/07/13 12:10:58 UTC
flink git commit: [hotfix] Reuse getMaxJvmHeapMemory() in
EnvironmentInformation#getSizeOfFreeHeapMemory()
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....@data-artisans.com>
Authored: Wed Jul 13 10:23:17 2016 +0200
Committer: zentol <ch...@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();
}
/**