Github user uce commented on a diff in the pull request:

    https://github.com/apache/flink/pull/859#discussion_r32957111
  
    --- Diff: 
flink-runtime/src/main/java/org/apache/flink/runtime/util/EnvironmentInformation.java
 ---
    @@ -137,7 +137,13 @@ public static long getSizeOfFreeHeapMemoryWithDefrag() 
{
         */
        public static long getSizeOfFreeHeapMemory() {
                Runtime r = Runtime.getRuntime();
    -           return r.maxMemory() - r.totalMemory() + r.freeMemory();
    +           long maxMemory = r.maxMemory();
    +           if (maxMemory == Long.MAX_VALUE) {
    +                   // workaround for some JVM versions
    +                   return r.freeMemory();
    --- End diff --
    
    I haven't tested this yet, but I think this [will not 
work](http://stackoverflow.com/questions/12807797/java-get-available-memory), 
because `freeMemory` returns to the free memory from the currently allocated 
memory. The JVM allocates memory in chunks. Free memory refers to how much of 
these allocated chunks is free.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to