Return JVM Memory Stats for Apache Tomcat Server.
        
        @return: Dictionary of memory utilization stats.
185140
def getMemoryStats(self):
        
        if self._statusxml is None:
            self.initStats()
        node = self._statusxml.find('jvm/memory')
        memstats = {}
        if node is not None:
            for (key,val) in node.items():
                memstats[key] = util.parse_value(val)
        return memstats
1141362
public static long getTotalPhysicalMemory() {
   long memory = -1;
   try {
     MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
     Object attribute = mBeanServer.getAttribute(new ObjectName("java.lang","type","OperatingSystem"), "TotalPhysicalMemorySize");
     return (Long) attribute;
   } catch (Throwable e) { e.printStackTrace(); }
   return memory;
 }
1272172
@Override
    public String[] getAllCacheStatistics() {
        DCache cache = null;
        if (ServerCache.servletCacheEnabled) {
            cache = ServerCache.cache;
        }
        String stats[] = null;
        if (cache != null) {
            Map statistics = getCacheStatisticsMap(cache.getCacheStatistics());
            Iterator keys = statistics.keySet().iterator();
            Iterator values = statistics.values().iterator();
            stats = new String[statistics.size()];
            int i = 0;
            while (keys.hasNext()) {
                stats[i] = keys.next() + "=" + values.next();
                i++;
            }
        } else {
            stats = new String[0];
            // DYNA1059W=DYNA1059W: WebSphere Dynamic Cache instance named {0} cannot be used because of Dynamic Servlet cache service has not be started.
            Tr.error(tc, "DYNA1059W", new Object[] { DCacheBase.DEFAULT_CACHE_NAME });
        }

        return stats;
    }
1112223
def get_shared_memory_bytes():
    
    # Make sure this is only called on Linux.
    assert sys.platform == "linux" or sys.platform == "linux2"

    shm_fd = os.open("/dev/shm", os.O_RDONLY)
    try:
        shm_fs_stats = os.fstatvfs(shm_fd)
        # The value shm_fs_stats.f_bsize is the block size and the
        # value shm_fs_stats.f_bavail is the number of available
        # blocks.
        shm_avail = shm_fs_stats.f_bsize * shm_fs_stats.f_bavail
    finally:
        os.close(shm_fd)

    return shm_avail
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
342432
def memory():
    

    mem_info = dict()

    for k, v in psutil.virtual_memory()._asdict().items():
           mem_info[k] = int(v)
           
    return mem_info
213017
def getTotalCpuTimeAndMemoryUsage():
    
    me = resource.getrusage(resource.RUSAGE_SELF)
    childs = resource.getrusage(resource.RUSAGE_CHILDREN)
    totalCpuTime = me.ru_utime+me.ru_stime+childs.ru_utime+childs.ru_stime
    totalMemoryUsage = me.ru_maxrss+ me.ru_maxrss
    return totalCpuTime, totalMemoryUsage
1058761
def get_queue_stats(self):
        '''
        
        '''
        self.logger.debug("Gathering queue based stats")

        the_dict = {}
        keys = self.redis_conn.keys('*:*:queue')
        total_backlog = 0
        for key in keys:
            elements = key.split(":")
            spider = elements[0]
            domain = elements[1]
            spider = 'queue_' + spider

            if spider not in the_dict:
                the_dict[spider] = {
                    'spider_backlog': 0,
                    'num_domains': 0,
                    'domains': []
                }

            count = self.redis_conn.zcard(key)
            total_backlog += count
            the_dict[spider]['spider_backlog'] += count
            the_dict[spider]['num_domains'] += 1
            the_dict[spider]['domains'].append({'domain': domain,
                                                'backlog': count})

        the_dict['total_backlog'] = total_backlog
        ret_dict = {
            'queues': the_dict
        }

        return ret_dict
630436
def metrics(self):
        
        masterThrp, backupThrp = self.getThroughputs(self.instances.masterId)
        r = self.instance_throughput_ratio(self.instances.masterId)
        m = [
            ("{} Monitor metrics:".format(self), None),
            ("Delta", self.Delta),
            ("Lambda", self.Lambda),
            ("Omega", self.Omega),
            ("instances started", self.instances.started),
            ("ordered request counts",
             {i: r[0] for i, r in self.numOrderedRequests.items()}),
            ("ordered request durations",
             {i: r[1] for i, r in self.numOrderedRequests.items()}),
            ("master request latencies", self.masterReqLatencies),
            ("client avg request latencies", {i: self.getLatency(i)
                                              for i in self.instances.ids}),
            ("throughput", {i: self.getThroughput(i)
                            for i in self.instances.ids}),
            ("master throughput", masterThrp),
            ("total requests", self.totalRequests),
            ("avg backup throughput", backupThrp),
            ("master throughput ratio", r)]
        return m
824490
def gather_data(registry):
    """"""

    # Get the host name of the machine
    host = socket.gethostname()

    # Create our collectors
    ram_metric = Gauge("memory_usage_bytes", "Memory usage in bytes.",
                       {'host': host})
    cpu_metric = Gauge("cpu_usage_percent", "CPU usage percent.",
                       {'host': host})

    # register the metric collectors
    registry.register(ram_metric)
    registry.register(cpu_metric)

    # Start gathering metrics every second
    while True:
        time.sleep(1)

        # Add ram metrics
        ram = psutil.virtual_memory()
        swap = psutil.swap_memory()

        ram_metric.set({'type': "virtual", }, ram.used)
        ram_metric.set({'type': "virtual", 'status': "cached"}, ram.cached)
        ram_metric.set({'type': "swap"}, swap.used)

        # Add cpu metrics
        for c, p in enumerate(psutil.cpu_percent(interval=1, percpu=True)):
            cpu_metric.set({'core': c}, p)
1183858
private int getMemory(final int requestedMemory) {
    final int maxMemory = applicationResponse.getMaximumResourceCapability().getMemory();
    final int amMemory;

    if (requestedMemory <= maxMemory) {
      amMemory = requestedMemory;
    } else {
      LOG.log(Level.WARNING,
          "Requested {0}MB of memory for the driver. " +
              "The max on this YARN installation is {1}. " +
              "Using {1} as the memory for the driver.",
          new Object[]{requestedMemory, maxMemory});
      amMemory = maxMemory;
    }
    return amMemory;
  }
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);
  }
794421
public static String formatUsedMemory() {
		Runtime runtime = Runtime.getRuntime();
		long usedMemory = Math.max(0, runtime.totalMemory() - runtime.freeMemory());

		return MemoryUnitFormat.getMemoryUnitInstance().format(usedMemory);
	}
16388
public ArrayList<OvhRtmMemory> serviceName_statistics_memory_GET(String serviceName) throws IOException {
		String qPath = "/dedicated/server/{serviceName}/statistics/memory";
		StringBuilder sb = path(qPath, serviceName);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, t9);
	}
677473
def get_memory_usage():
    
    process = psutil.Process(os.getpid())
    mem = process.memory_info().rss
    return mem / (1024 * 1024)
127837
def memory():
    '''
    
    '''

    # test defaults
    # --memory-block-size = 10M
    # --memory-total-size = 1G

    # We test memory read / write against global / local scope of memory
    # Test data
    memory_oper = ['read', 'write']
    memory_scope = ['local', 'global']

    # Initializing the test variables
    test_command = 'sysbench --num-threads=64 --test=memory '
    test_command += '--memory-oper={0} --memory-scope={1} '
    test_command += '--memory-block-size=1K --memory-total-size=32G run '
    result = None
    ret_val = {}

    # Test begins!
    for oper in memory_oper:
        for scope in memory_scope:
            key = 'Operation: {0} Scope: {1}'.format(oper, scope)
            run_command = test_command.format(oper, scope)
            result = __salt__['cmd.run'](run_command)
            ret_val[key] = _parser(result)

    return ret_val
243818
def stats(self):
        
        status, _, body = self._request('GET', self.stats_path(),
                                        {'Accept': 'application/json'})
        if status == 200:
            return json.loads(bytes_to_str(body))
        else:
            return None