Returns the amount of free memory remaining.

@return the amount of free memory remaining if successful, -1 return indicates failure.
333139
public long getFreeMemory() {
    try {
      return (long) mBeanServer.getAttribute(new ObjectName("java.lang", "type", "OperatingSystem"), "FreePhysicalMemorySize");
    } catch (Exception e) {
      if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("An exception occurred during memory check", e);
      }
    }
    return -1;
  }
880860
public int getTotalFree(){
		int total=0;
		for (int i=0; i < this.partitionCount && this.partitions[i] != null ; i++){
			total+=this.partitions[i].getAvailableConnections();
		}
		return total;
	}
1259503
@Override
	public int remainingCapacity() {
		if (sizeLimit > 0){
			int remaining = sizeLimit - size();
			return remaining < 0 ? 0 : remaining;
		}else{
			return queue.remainingCapacity();
		}
	}
350465
def memory_used(self):
        
        if self._end_memory:
            memory_used = self._end_memory - self._start_memory
            return memory_used
        else:
            return None
1166703
public static double getSystemMemoryInfo() throws Exception {
        int total = 0;
        Process process = Runtime.getRuntime().exec("tasklist");
        String result = IOUtils.read(process.getInputStream(), Charset.defaultCharset().name());
        String[] results = result.split("\\n");
        for (String str : results) {
            Pattern pattern = Pattern.compile(".*\\s([0-9]{0,},[0-9]+)\\sK.*");
            Matcher matcher = pattern.matcher(str);
            if (matcher.find()) {
                String memorySizeStr = matcher.group(1).replace(",", "");
                int memorySize = Integer.parseInt(memorySizeStr);
                total += memorySize;
            }
        }
        return (double) total / 1024;
    }
495847
def get_free_memory_win():
    
    stat = MEMORYSTATUSEX()
    ctypes.windll.kernel32.GlobalMemoryStatusEx(ctypes.byref(stat))
    return int(stat.ullAvailPhys / 1024 / 1024)
60654
public int dataAvailable() {
        if (readBuffer.position() < fillBuffer.position()) {
            return readBuffer.remaining();
        } else if (readBuffer.position() > fillBuffer.position()) {
            return capacity - fillBuffer.remaining();
        } else {
            if (readBuffer.hasRemaining()) {
                return readBuffer.remaining() + fillBuffer.position();
            } else {
                return 0;
            }
        }
    }
116273
protected static Long getTotalExternalStorage() {
        try {
            if (isExternalStorageMounted()) {
                File path = Environment.getExternalStorageDirectory();
                StatFs stat = new StatFs(path.getPath());
                long blockSize = stat.getBlockSize();
                long totalBlocks = stat.getBlockCount();
                return totalBlocks * blockSize;
            }
        } catch (Exception e) {
            Log.e(TAG, "Error getting total external storage amount.", e);
        }

        return null;
    }
984300
public int getAvailable()
    throws IOException
  {
    if (_isPartDone)
      return 0;
    else if (_peekOffset < _peekLength)
      return _peekLength - _peekOffset;
    else {
      int ch = read();
      if (ch < 0)
        return 0;
      _peekOffset = 0;
      _peekLength = 1;
      _peek[0] = (byte) ch;

      return 1;
    }
  }
1195406
public static String memoryUsage() {
    final Runtime runtime = Runtime.getRuntime();

    runtime.gc();

    final long max = runtime.maxMemory();
    final long total = runtime.totalMemory();
    final long free = runtime.freeMemory();
    final long used = total - free;

    return String.format("%d\t%d\t%d\t%d", max, total, free, used);
  }
1166799
public int size() {
        int count = 0;

        for (int i = 0, size = mScrapLength.size(); i < size; i++) {
            int val = mScrapLength.valueAt(i);
            count += val;
        }

        return count;
    }
668202
public String getMemoryUsageAsString() {
        long len = weights.length;
        return ((8L + 4L + 4L) * len
                + changedNodes.getCapacity() * 4L
                + heap.getCapacity() * (4L + 4L)) / Helper.MB
                + "MB";
    }
1276911
public int size() {
        int n = 0;
        int count = getRangeCount();
        for (int i = 0; i < count; ++i) {
            n += getRangeEnd(i) - getRangeStart(i) + 1;
        }
        return n + strings.size();
    }
670722
public int getTotalLeased(){
		int total=0;
		for (int i=0; i < this.partitionCount && this.partitions[i] != null; i++){
			total+=this.partitions[i].getCreatedConnections()-this.partitions[i].getAvailableConnections();
		}
		return total;
	}
428083
@Override
    public long getTotalSize() {
        if (totalSize == HasTotalSize.NOT_DEPLETED && !hasNext()) {
            totalSize = hasTotalSize == null ? HasTotalSize.NOT_DEPLETED : hasTotalSize.getTotalSize();
        }
        return totalSize;
    }
327819
public int getNumberAvailable() {
        int result = 0;
        for (int i = 0; i < data.size(); i++) {
            if (data.get(i) != null) {
                result += 1;
            }
        }
        return result;
    }
422163
public synchronized int allocateNextChunk() {
        if ((used_bytes.longValue() + (long) mem_chunksize) > max_allowed_bytes) {
            logger.info("No memory left");
            return 0;
        }
        used_bytes.set(used_bytes.longValue() + (long) mem_chunksize);
        return mem_chunksize;
    }