public static long getAvailableMemory(Logger logger) {
    long free = 0;
    Pattern p = Pattern.compile("(.*)?:\\s+(\\d+)( kB)?");

    try (FileInputStream fileInputStream = new FileInputStream("/proc/meminfo");
        InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream);
        BufferedReader br = new BufferedReader(inputStreamReader)) {

      String line;
      while ((line = br.readLine()) != null) {
        Matcher m = p.matcher(line);
        if (m.matches() && ("MemFree".equals(m.group(1)) || "Cached".equals(m.group(1)))) {
          free += Long.parseLong(m.group(2));
        }
      }

      // convert to bytes
      return 1024 * free;

    } catch (IOException e) {
      logger.warn("Error determining free memory", e);
      return Long.MAX_VALUE;
    }
  }
Returns the available system memory (free + cached).

@param logger the logger
@return the available memory in bytes
geode-core/src/main/java/org/apache/geode/internal/statistics/platform/LinuxProcFsStatistics.java