Return the amount of free and total device memory.

    Returns
    -------
    free : long
        Free memory in bytes.
    total : long
        Total memory in bytes.
351730
def cudaMemGetInfo():
    

    free = ctypes.c_size_t()
    total = ctypes.c_size_t()
    status = _libcudart.cudaMemGetInfo(ctypes.byref(free),
                                       ctypes.byref(total))
    cudaCheckStatus(status)
    return free.value, total.value
966917
private boolean isRunningOutOfMemory() {
    StorageLevel level = raft.getStorage().storageLevel();
    if (level == StorageLevel.MEMORY || level == StorageLevel.MAPPED) {
      long freeMemory = raft.getStorage().statistics().getFreeMemory();
      long totalMemory = raft.getStorage().statistics().getTotalMemory();
      if (freeMemory > 0 && totalMemory > 0) {
        return freeMemory / (double) totalMemory < raft.getStorage().freeMemoryBuffer();
      }
    }
    return false;
  }
677473
def get_memory_usage():
    
    process = psutil.Process(os.getpid())
    mem = process.memory_info().rss
    return mem / (1024 * 1024)
535960
public long getPreciseFreeMemory(int deviceId) {
        // we refresh free memory on device
        val extFree = NativeOpsHolder.getInstance().getDeviceNativeOps().getDeviceFreeMemory(deviceId);
        //freePerDevice.get(deviceId).set(extFree);

        return extFree;
    }
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;
  }
11204
public int freeBytes()
    {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "freeBytes", this);

        int freeBytes = 0;

        try
        {
            int currentCursorPosition = _fileBuffer.position();
            int fileLength = _fileBuffer.capacity();

            freeBytes = fileLength - currentCursorPosition;

            if (freeBytes < 0)
            {
                freeBytes = 0;
            }
        } catch (Throwable exc)
        {
            FFDCFilter.processException(exc, "com.ibm.ws.recoverylog.spi.LogFileHandle.freeBytes", "956", this);
            freeBytes = 0;
        }

        if (tc.isEntryEnabled())
            Tr.exit(tc, "freeBytes", new Integer(freeBytes));

        return freeBytes;
    }
894306
def read_memory(self):
        
        if self.mem_empty == True:
            if self.mem_idx == 0:
                m_x = np.zeros(self.n)
                m_d = 0
            else:
                m_x = np.mean(self.mem_x[:self.mem_idx+1], axis=0)
                m_d = np.mean(self.mem_d[:self.mem_idx])
        else:
            m_x = np.mean(self.mem_x, axis=0)
            m_d = np.mean(np.delete(self.mem_d, self.mem_idx))
        self.mem_idx += 1
        if self.mem_idx > len(self.mem_x)-1:
            self.mem_idx = 0
            self.mem_empty = False
        return m_d, m_x
812120
def dumpfree(self):
        
        fmt = "L" if self.version > 15 else "H"
        hdrsize = 8 if self.version > 15 else 4
        pn = self.firstfree
        if pn == 0:
            print("no free pages")
            return
        while pn:
            self.fh.seek(pn * self.pagesize)
            data = self.fh.read(self.pagesize)
            if len(data) == 0:
                print("could not read FREE data at page %06x" % pn)
                break
            count, nextfree = struct.unpack_from("<" + (fmt * 2), data)
            freepages = list(struct.unpack_from("<" + (fmt * count), data, hdrsize))
            freepages.insert(0, pn)
            for pn in freepages:
                self.fh.seek(pn * self.pagesize)
                data = self.fh.read(self.pagesize)
                print("%06x: free: %s" % (pn, hexdump(data[:64])))
            pn = nextfree
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;
    }
858551
def get_data(self):
        
        data = []
        if self.counts:
            time_sec = self.duration
            memory_mb = self.mem / 1024. / 1024. if self.measuremem else 0
            data.append((self.operation, time_sec, memory_mb, self.counts))
        return numpy.array(data, perf_dt)
615055
def get_system_memory():
    
    # Try to accurately figure out the memory limit if we are in a docker
    # container. Note that this file is not specific to Docker and its value is
    # often much larger than the actual amount of memory.
    docker_limit = None
    memory_limit_filename = "/sys/fs/cgroup/memory/memory.limit_in_bytes"
    if os.path.exists(memory_limit_filename):
        with open(memory_limit_filename, "r") as f:
            docker_limit = int(f.read())

    # Use psutil if it is available.
    psutil_memory_in_bytes = None
    try:
        import psutil
        psutil_memory_in_bytes = psutil.virtual_memory().total
    except ImportError:
        pass

    if psutil_memory_in_bytes is not None:
        memory_in_bytes = psutil_memory_in_bytes
    elif sys.platform == "linux" or sys.platform == "linux2":
        # Handle Linux.
        bytes_in_kilobyte = 1024
        memory_in_bytes = vmstat("total memory") * bytes_in_kilobyte
    else:
        # Handle MacOS.
        memory_in_bytes = sysctl(["sysctl", "hw.memsize"])

    if docker_limit is not None:
        return min(docker_limit, memory_in_bytes)
    else:
        return memory_in_bytes
700260
def get_size(self):
        
        if self._size is None:
            self._size = self._filepath.stat().st_size
        return self._size
416994
def free_extent_count(self):
        
        self.open()
        count = lvm_vg_get_free_extent_count(self.handle)
        self.close()
        return count
1190056
def get_memory_info(self) -> str:
        ''''''
        output, _ = self._execute(
            '-s', self.device_sn, 'shell', 'cat', '/proc/meminfo')
        return output
1257541
protected int getFreeSpace()
    {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "getFreeSpace", this);

        final int freeBytes = _activeFile.freeBytes();

        if (tc.isEntryEnabled())
            Tr.exit(tc, "getFreeSpace", freeBytes);

        return freeBytes;
    }
673989
def free_memory(self):
        """"""
        self.main.free_memory()
        QTimer.singleShot(self.INITIAL_FREE_MEMORY_TIME_TRIGGER,
                          lambda: self.main.free_memory())
        QTimer.singleShot(self.SECONDARY_FREE_MEMORY_TIME_TRIGGER,
                          lambda: self.main.free_memory())
872813
def total(self):
        
        if self.system_total.available:
            return self.system_total.vsz
        elif self.asizeof_total: # pragma: no cover
            return self.asizeof_total
        else: # pragma: no cover
            return self.tracked_total