Get virtual size of current process by reading the process' stat file.
        This should work for Linux.
182061
def update(self):
        
        try:
            stat = open('/proc/self/stat')
            status = open('/proc/self/status')
        except IOError: # pragma: no cover
            return False
        else:
            stats = stat.read().split()
            self.vsz = int( stats[22] )
            self.rss = int( stats[23] ) * self.pagesize
            self.pagefaults = int( stats[11] )

            for entry in status.readlines():
                key, value = entry.split(':')
                size_in_bytes = lambda x: int(x.split()[0]) * 1024
                if key == 'VmData':
                    self.data_segment = size_in_bytes(value)
                elif key == 'VmExe':
                    self.code_segment = size_in_bytes(value)
                elif key == 'VmLib':
                    self.shared_segment = size_in_bytes(value)
                elif key == 'VmStk':
                    self.stack_segment = size_in_bytes(value)
                key = self.key_map.get(key)
                if key:
                    self.os_specific.append((key, value.strip()))


            stat.close()
            status.close()
            return True
506749
public int getDataSize() {
        // Data size is given by lvs
        int size = 0;
        for(int i=0; i<numLVs; i++) {
            size += IOUtils.toInt(lvs[i]);
        }
        return size;
    }
638964
def dev_size(self, units="MiB"):
        
        self.open()
        size = lvm_pv_get_dev_size(self.handle)
        self.close()
        return size_convert(size, units)
37749
def get_size(vm_):
    '''
    
    '''
    sizes = avail_sizes()
    vm_size = six.text_type(config.get_cloud_config_value(
        'size', vm_, __opts__, search_global=False
    ))

    if not vm_size:
        raise SaltCloudNotFound('No size specified for this VM.')

    if vm_size and six.text_type(vm_size) in sizes:
        return sizes[vm_size]['InstanceTypeId']

    raise SaltCloudNotFound(
        'The specified size, \'{0}\', could not be found.'.format(vm_size)
    )
1106087
def calculate_size(uuid, partition_id, interrupt):
    
    data_size = 0
    data_size += calculate_size_str(uuid)
    data_size += INT_SIZE_IN_BYTES
    data_size += BOOLEAN_SIZE_IN_BYTES
    return data_size
15127
def GetMemTargetSizeMB(self):
        ''''''
        counter = c_uint()
        ret = vmGuestLib.VMGuestLib_GetMemTargetSizeMB(self.handle.value, byref(counter))
        if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
        return counter.value
247806
def size():
    
    try:
        assert os != 'nt' and sys.stdout.isatty()
        rows, columns = os.popen('stty size', 'r').read().split()
    except (AssertionError, AttributeError, ValueError):
        # in case of failure, use dimensions of a full screen 13" laptop
        rows, columns = DEFAULT_HEIGHT, DEFAULT_WIDTH

    return int(rows), int(columns)
567205
private static long getSizeOfPhysicalMemory() {
		switch (OperatingSystem.getCurrentOperatingSystem()) {
			case LINUX:
				return getSizeOfPhysicalMemoryForLinux();
				
			case WINDOWS:
				return getSizeOfPhysicalMemoryForWindows();
				
			case MAC_OS:
				return getSizeOfPhysicalMemoryForMac();
				
			case FREE_BSD:
				return getSizeOfPhysicalMemoryForFreeBSD();
				
			case UNKNOWN:
				LOG.error("Cannot determine size of physical memory for unknown operating system");
				return -1;
				
			default:
				LOG.error("Unrecognized OS");
				return -1;
		}
	}
316875
def size(self):
        """"""
        total_size = 0
        for dir_path, dir_names, filenames in os.walk(self.dir):
            for f in filenames:
                fp = os.path.join(dir_path, f)
                total_size += os.path.getsize(fp)
        return total_size
122757
def _get_total_read_size(self):
        """"""
        if self.read_size:
            read_size = EVENT_SIZE * self.read_size
        else:
            read_size = EVENT_SIZE
        return read_size
101519
def file_size(self):
        
        stream = self.get_file_stream()
        stream.seek(0, os.SEEK_END)
        return stream.tell()
1001748
public void read() {
    String pid = "-1";
    try {
      pid = getProcessId();
      _pid = pid;
    }
    catch (Exception ignore) {}

    File f = new File ("/proc/stat");
    if (! f.exists()) {
      return;
    }

    try {
      readSystemProcFile();
      readProcessProcFile(pid);
      readProcessNumOpenFds(pid);
      readProcessStatusFile(pid);
      parseSystemProcFile(_systemData);
      parseProcessProcFile(_processData);
      parseProcessStatusFile(_processStatus);
    }
    catch (Exception ignore) {}
  }
1151210
def getVMstats(self):
        
        info_dict = {}
        try:
            fp = open(vmstatFile, 'r')
            data = fp.read()
            fp.close()
        except:
            raise IOError('Failed reading stats from file: %s' % vmstatFile)
        for line in data.splitlines():
            cols = line.split()
            if len(cols) == 2:
                info_dict[cols[0]] = cols[1]
        return info_dict
1322050
def get_memory_size(self):
        """"""
        n = sys.getsizeof(self)
        n += sys.getsizeof(self.padding)
        n += total_size(self.start_addr)
        n += total_size(self._buf)
        n += sys.getsizeof(self._offset)
        return n
535633
def mem_size(self):
        
        result = self.shell.execute(self.commands.mem_size.value)
        stdout = self.shell.decode(result['stdout'])
        stderr = self.shell.decode(result['stderr'])
        return int(stdout)
545915
def get_size(self):
    
    if not self._is_open:
      raise IOError('Not opened.')

    if self._fsntfs_data_stream:
      return self._fsntfs_data_stream.get_size()
    return self._fsntfs_file_entry.get_size()
652520
private static long getSizeOfPhysicalMemoryForMac() {

		BufferedReader bi = null;

		try {
			Process proc = Runtime.getRuntime().exec("sysctl hw.memsize");

			bi = new BufferedReader(
					new InputStreamReader(proc.getInputStream()));

			String line;

			while ((line = bi.readLine()) != null) {
				if (line.startsWith("hw.memsize")) {
					long memsize = Long.parseLong(line.split(":")[1].trim());
					bi.close();
					proc.destroy();
					return memsize;
				}
			}

		} catch (Exception e) {
			LOG.error(e);
			return -1;
		} finally {
			if (bi != null) {
				try {
					bi.close();
				} catch (IOException ioe) {
				}
			}
		}
		return -1;
	}