当前位置: 首页>>代码示例>>Java>>正文


Java MemoryMXBean.getNonHeapMemoryUsage方法代码示例

本文整理汇总了Java中java.lang.management.MemoryMXBean.getNonHeapMemoryUsage方法的典型用法代码示例。如果您正苦于以下问题:Java MemoryMXBean.getNonHeapMemoryUsage方法的具体用法?Java MemoryMXBean.getNonHeapMemoryUsage怎么用?Java MemoryMXBean.getNonHeapMemoryUsage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.lang.management.MemoryMXBean的用法示例。


在下文中一共展示了MemoryMXBean.getNonHeapMemoryUsage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: call

import java.lang.management.MemoryMXBean; //导入方法依赖的package包/类
@Override
public String call() {
  Map<String, String> memoryMap = new HashMap<>();
  OperatingSystemMXBean osMxBean = ManagementFactory.getOperatingSystemMXBean();
  double cpu = osMxBean.getSystemLoadAverage();
  memoryMap.put("cpuLoad", String.format(doubleStringFormatter, round(cpu, doubleRoundPlaces)));

  ThreadMXBean threadmxBean = ManagementFactory.getThreadMXBean();
  int threadCount = threadmxBean.getThreadCount();
  memoryMap.put("cpuRunningThreads", String.valueOf(threadCount));

  MemoryMXBean memBean = ManagementFactory.getMemoryMXBean();
  MemoryUsage memHeapUsage = memBean.getHeapMemoryUsage();
  MemoryUsage nonHeapUsage = memBean.getNonHeapMemoryUsage();
  memoryMap.put("heapInit", String.valueOf(memHeapUsage.getInit()));
  memoryMap.put("heapMax", String.valueOf(memHeapUsage.getMax()));
  memoryMap.put("heapCommit", String.valueOf(memHeapUsage.getCommitted()));
  memoryMap.put("heapUsed", String.valueOf(memHeapUsage.getUsed()));
  memoryMap.put("nonHeapInit", String.valueOf(nonHeapUsage.getInit()));
  memoryMap.put("nonHeapMax", String.valueOf(nonHeapUsage.getMax()));
  memoryMap.put("nonHeapCommit", String.valueOf(nonHeapUsage.getCommitted()));
  memoryMap.put("nonHeapUsed", String.valueOf(nonHeapUsage.getUsed()));
  return memoryMap.toString();
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:25,代码来源:MetricsServoRegistry.java

示例2: monitorMemory

import java.lang.management.MemoryMXBean; //导入方法依赖的package包/类
public String monitorMemory() {
	StringBuilder sb = new StringBuilder("Memory:");
	MemoryMXBean mmbean = ManagementFactory.getMemoryMXBean();
	MemoryUsage hmu = mmbean.getHeapMemoryUsage();
	sb.append("[HeapMemoryUsage:");
	sb.append(" Used=" + formatBytes(hmu.getUsed() * 8));
	sb.append(" Committed=" + formatBytes(hmu.getCommitted() * 8));
	sb.append("]");

	MemoryUsage nhmu = mmbean.getNonHeapMemoryUsage();
	sb.append("[NonHeapMemoryUsage:");
	sb.append(" Used=" + formatBytes(nhmu.getUsed() * 8));
	sb.append(" Committed=" + formatBytes(nhmu.getCommitted() * 8));
	sb.append("]");
	return sb.toString();
}
 
开发者ID:blusechen,项目名称:venus,代码行数:17,代码来源:VMMonitor.java

示例3: getMemoryUsageStatsAsString

import java.lang.management.MemoryMXBean; //导入方法依赖的package包/类
/**
 * Gets the memory footprint of the JVM in a string representation.
 *
 * @return A string describing how much heap memory and direct memory are allocated and used.
 */
public static String getMemoryUsageStatsAsString(MemoryMXBean memoryMXBean) {
	MemoryUsage heap = memoryMXBean.getHeapMemoryUsage();
	MemoryUsage nonHeap = memoryMXBean.getNonHeapMemoryUsage();

	long heapUsed = heap.getUsed() >> 20;
	long heapCommitted = heap.getCommitted() >> 20;
	long heapMax = heap.getMax() >> 20;

	long nonHeapUsed = nonHeap.getUsed() >> 20;
	long nonHeapCommitted = nonHeap.getCommitted() >> 20;
	long nonHeapMax = nonHeap.getMax() >> 20;

	return String.format("Memory usage stats: [HEAP: %d/%d/%d MB, " +
			"NON HEAP: %d/%d/%d MB (used/committed/max)]",
			heapUsed, heapCommitted, heapMax, nonHeapUsed, nonHeapCommitted, nonHeapMax);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:22,代码来源:MemoryLogger.java

示例4: memoryUsage

import java.lang.management.MemoryMXBean; //导入方法依赖的package包/类
private MemoryUsage memoryUsage() {
    MemoryUsage usage = new MemoryUsage();
    MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();
    java.lang.management.MemoryUsage heapMemoryUsage = memoryMXBean.getHeapMemoryUsage();
    usage.heapInit = heapMemoryUsage.getInit();
    usage.heapUsed = heapMemoryUsage.getUsed();
    usage.heapCommitted = heapMemoryUsage.getCommitted();
    usage.heapMax = heapMemoryUsage.getMax();

    java.lang.management.MemoryUsage nonHeapMemoryUsage = memoryMXBean.getNonHeapMemoryUsage();
    usage.nonHeapInit = nonHeapMemoryUsage.getInit();
    usage.nonHeapUsed = nonHeapMemoryUsage.getUsed();
    usage.nonHeapCommitted = nonHeapMemoryUsage.getCommitted();
    usage.nonHeapMax = nonHeapMemoryUsage.getMax();

    return usage;
}
 
开发者ID:neowu,项目名称:core-ng-project,代码行数:18,代码来源:MemoryUsageController.java

示例5: getMetrics

import java.lang.management.MemoryMXBean; //导入方法依赖的package包/类
@Override
public Map<String, Metric> getMetrics() {
    Map<String, Metric> metrics = super.getMetrics();
    MemoryMXBean memMxBean = ManagementFactory.getMemoryMXBean();

    registerGauge(metrics, MEMORY_OBJ_PENDING_FINALIZATION_COUNT_METRIC_NAME, memMxBean.getObjectPendingFinalizationCount());

    MemoryUsage heapMemUsage = memMxBean.getHeapMemoryUsage(), nonHeapMemUsage = memMxBean.getNonHeapMemoryUsage();

    registerMemoryUsageMetrics(metrics, MEMORY_HEAP_METRIC_NAME_PREFIX, heapMemUsage);
    registerMemoryUsageMetrics(metrics, MEMORY_NON_HEAP_METRIC_NAME_PREFIX, nonHeapMemUsage);
    registerMemoryUsageMetrics(metrics, MEMORY_TOTAL_METRIC_NAME_PREFIX, (heapMemUsage.getCommitted() + nonHeapMemUsage.getCommitted()),
        (heapMemUsage.getInit() + nonHeapMemUsage.getInit()), -1, (heapMemUsage.getUsed() + nonHeapMemUsage.getUsed()),
        (heapMemUsage.getMax() + nonHeapMemUsage.getMax()));

    ManagementFactory.getMemoryPoolMXBeans().stream().filter(MemoryPoolMXBean::isValid)
        .forEach(memPoolMxBean -> registerMemoryPoolMetrics(metrics, memPoolMxBean));

    ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class).stream().forEach(bufferPoolMxBean -> registerBufferPoolMetrics(metrics, bufferPoolMxBean));

    return metrics;
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:23,代码来源:MemoryMetricSet.java

示例6: getMemoryUsageStatsAsString

import java.lang.management.MemoryMXBean; //导入方法依赖的package包/类
private String getMemoryUsageStatsAsString(MemoryMXBean memoryMXBean) {
	MemoryUsage heap = memoryMXBean.getHeapMemoryUsage();
	MemoryUsage nonHeap = memoryMXBean.getNonHeapMemoryUsage();

	int mb = 1 << 20;

	int heapUsed = (int) (heap.getUsed() / mb);
	int heapCommitted = (int) (heap.getCommitted() / mb);
	int heapMax = (int) (heap.getMax() / mb);

	int nonHeapUsed = (int) (nonHeap.getUsed() / mb);
	int nonHeapCommitted = (int) (nonHeap.getCommitted() / mb);
	int nonHeapMax = (int) (nonHeap.getMax() / mb);

	String msg = String.format("Memory usage stats: [HEAP: %d/%d/%d MB, NON HEAP: %d/%d/%d MB (used/comitted/max)]",
			heapUsed, heapCommitted, heapMax, nonHeapUsed, nonHeapCommitted, nonHeapMax);

	return msg;
}
 
开发者ID:citlab,项目名称:vs.msc.ws14,代码行数:20,代码来源:TaskManager.java

示例7: reportNonHeapUsage

import java.lang.management.MemoryMXBean; //导入方法依赖的package包/类
private void reportNonHeapUsage(MemoryMXBean memoryMxBean, MetricRecorder.Context metricContext) {
    MemoryUsage usage = memoryMxBean.getNonHeapMemoryUsage();

    long used = usage.getUsed();
    metricContext.record(NON_HEAP, used / M, Unit.MEGABYTE);

    long max = usage.getMax();
    if (max >= 0) {
        metricContext.record(NON_HEAP_MAX, max / M, Unit.MEGABYTE);

        double used_percent = 100.0 * ((double)used/(double)max);
        metricContext.record(NON_HEAP_USED, used_percent, Unit.PERCENT);
    }
}
 
开发者ID:awslabs,项目名称:swage,代码行数:15,代码来源:MemorySensor.java

示例8: Datum

import java.lang.management.MemoryMXBean; //导入方法依赖的package包/类
/**
 * Constructor accepts some system values and generates some Java values.
 *
 * @param rss Resident set size.
 */
Datum(long rss) {
    MemoryMXBean mmxb = ManagementFactory.getMemoryMXBean();
    MemoryUsage muheap = mmxb.getHeapMemoryUsage();
    MemoryUsage musys = mmxb.getNonHeapMemoryUsage();

    timestamp = System.currentTimeMillis();
    this.rss = rss;
    javatotalheapmem = muheap.getCommitted();
    javausedheapmem = muheap.getUsed();
    javatotalsysmem = musys.getCommitted();
    javausedsysmem = musys.getUsed();
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:18,代码来源:SystemStatsCollector.java

示例9: doMemoryUpdates

import java.lang.management.MemoryMXBean; //导入方法依赖的package包/类
private void doMemoryUpdates() {
    MemoryMXBean memoryMXBean =
           ManagementFactory.getMemoryMXBean();
    MemoryUsage memNonHeap =
            memoryMXBean.getNonHeapMemoryUsage();
    MemoryUsage memHeap =
            memoryMXBean.getHeapMemoryUsage();
    Runtime runtime = Runtime.getRuntime();

    metrics.setMetric("memNonHeapUsedM", memNonHeap.getUsed()/M);
    metrics.setMetric("memNonHeapCommittedM", memNonHeap.getCommitted()/M);
    metrics.setMetric("memHeapUsedM", memHeap.getUsed()/M);
    metrics.setMetric("memHeapCommittedM", memHeap.getCommitted()/M);
    metrics.setMetric("maxMemoryM", runtime.maxMemory()/M);
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:16,代码来源:JvmMetrics.java

示例10: run

import java.lang.management.MemoryMXBean; //导入方法依赖的package包/类
public void run() {
	bContinue = true;
	
	try {
		while (bContinue) {
	        MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();
	        MemoryUsage memoryUsageHeap = memoryMXBean.getHeapMemoryUsage(); 
	        MemoryUsage memoryUsageNonHeap = memoryMXBean.getNonHeapMemoryUsage();
	        
	        setUsageCounter("[Memory] Heap memory usage", memoryUsageHeap);
	        setUsageCounter("[Memory] Non heap memory usage", memoryUsageNonHeap);
	        setUsageCounter("[Memory] Total used", (memoryUsageHeap.getUsed() + memoryUsageNonHeap.getUsed()) / 1024 + "K");
	        
			synchronized (usageCounters) {
				List<String> ls = new ArrayList<String>();
				ls.addAll(usageCounters.keySet());
				Collections.sort(ls);
				for (String counter : ls) {
					Engine.logUsageMonitor.info(counter + ": " + usageCounters.get(counter));
				}
			}
		
			Thread.sleep(30000);
		}
	} catch (NullPointerException npe) {
		if (Engine.theApp == null) {
			// Engine.theApp == null probably means the engine is getting stopped
			// so gracefully ignore and exit thread
			return;
		}
		else {
			npe.printStackTrace();
		}
	} catch (Exception e) {
		e.printStackTrace();
	}

	usageCounters = null;
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:40,代码来源:UsageMonitor.java

示例11: PrintSystemMemoryUsage

import java.lang.management.MemoryMXBean; //导入方法依赖的package包/类
public void PrintSystemMemoryUsage(){
       MemoryMXBean membean = ManagementFactory.getMemoryMXBean( );
       MemoryUsage heap = membean.getHeapMemoryUsage( );
       System.out.println( "Heap Memory: " + heap.toString( ) );
       MemoryUsage nonheap = membean.getNonHeapMemoryUsage( );
       System.out.println( "NonHeap Memory: " + nonheap.toString( ) );


}
 
开发者ID:ParkJinSang,项目名称:Jinseng-Server,代码行数:10,代码来源:StatusReporter.java

示例12: showMemory

import java.lang.management.MemoryMXBean; //导入方法依赖的package包/类
public void showMemory() {
	MemoryMXBean membean = ManagementFactory.getMemoryMXBean();
	MemoryUsage heap = membean.getHeapMemoryUsage();
	System.out.println("Heap Memory: " + heap.toString());
	MemoryUsage nonheap = membean.getNonHeapMemoryUsage();
	System.out.println("NonHeap Memory: " + nonheap.toString());
}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:8,代码来源:CPUUsageTest.java

示例13: process

import java.lang.management.MemoryMXBean; //导入方法依赖的package包/类
@Override
public Object process(Object arg, Set<DistributedMember> members,
    GfxdConfigMessage<?> msg) {
  TreeMap<Object, Object> map = new TreeMap<Object, Object>();
  // GC information
  for (GarbageCollectorMXBean gcBean : ManagementFactory
      .getGarbageCollectorMXBeans()) {
    final String gcPrefix = "gc-" + gcBean.getName();
    map.put(gcPrefix + "-collection-count", gcBean.getCollectionCount());
    map.put(gcPrefix + "-collection-time", gcBean.getCollectionTime());
    map.put(gcPrefix + "-memory-pools",
        GemFireXDUtils.toCSV(gcBean.getMemoryPoolNames()));
  }
  // some thread information
  ThreadMXBean threadBean = ManagementFactory.getThreadMXBean();
  map.put("thread-count", threadBean.getThreadCount());
  map.put("thread-total-count", threadBean.getTotalStartedThreadCount());
  map.put("thread-peak-count", threadBean.getPeakThreadCount());
  // some memory information
  MemoryMXBean memBean = ManagementFactory.getMemoryMXBean();
  MemoryUsage heapUsage = memBean.getHeapMemoryUsage();
  MemoryUsage nonHeapUsage = memBean.getNonHeapMemoryUsage();
  map.put("memory-heap-max", heapUsage.getMax());
  map.put("memory-heap-committed", heapUsage.getCommitted());
  map.put("memory-heap-used", heapUsage.getUsed());
  map.put("memory-nonheap-max", nonHeapUsage.getMax());
  map.put("memory-nonheap-committed", nonHeapUsage.getCommitted());
  map.put("memory-nonheap-used", nonHeapUsage.getUsed());
  // some more runtime memory information
  Runtime rt = Runtime.getRuntime();
  map.put("memory-free", rt.freeMemory());
  map.put("memory-max", rt.maxMemory());
  map.put("memory-total", rt.totalMemory());
  map.put("available-processors", rt.availableProcessors());
  return map;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:37,代码来源:GfxdConfigMessage.java

示例14: doMemoryUpdates

import java.lang.management.MemoryMXBean; //导入方法依赖的package包/类
private void doMemoryUpdates() {
    MemoryMXBean memoryMXBean =
           ManagementFactory.getMemoryMXBean();
    MemoryUsage memNonHeap =
            memoryMXBean.getNonHeapMemoryUsage();
    MemoryUsage memHeap =
            memoryMXBean.getHeapMemoryUsage();
    metrics.setMetric("memNonHeapUsedM", memNonHeap.getUsed()/M);
    metrics.setMetric("memNonHeapCommittedM", memNonHeap.getCommitted()/M);
    metrics.setMetric("memHeapUsedM", memHeap.getUsed()/M);
    metrics.setMetric("memHeapCommittedM", memHeap.getCommitted()/M);
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:13,代码来源:JvmMetrics.java

示例15: getInodeLimitText

import java.lang.management.MemoryMXBean; //导入方法依赖的package包/类
public String getInodeLimitText() {
  long inodes = fsn.dir.totalInodes();
  long blocks = fsn.getBlocksTotal();
  long maxobjects = fsn.getMaxObjects();
  MemoryMXBean mem = ManagementFactory.getMemoryMXBean();

  MemoryUsage heap = mem.getHeapMemoryUsage();
  MemoryUsage nonHeap = mem.getNonHeapMemoryUsage();

  long totalHeap = heap.getUsed();
  long maxHeap = heap.getMax();
  long commitedHeap = heap.getCommitted();
  long initHeap = heap.getInit();

  long totalNonHeap = nonHeap.getUsed();
  long maxNonHeap = nonHeap.getMax();
  long commitedNonHeap = nonHeap.getCommitted();

  long used = (totalHeap * 100)/maxHeap;
  long usedNonHeap = (totalNonHeap * 100) / maxNonHeap;


  String str = inodes + " files and directories, " +
               blocks + " blocks = " +
               (inodes + blocks) + " total";
  if (maxobjects != 0) {
    long pct = ((inodes + blocks) * 100)/maxobjects;
    str += " / " + maxobjects + " (" + pct + "%)";
  }
  str += ".  Heap Size is " + StringUtils.byteDesc(totalHeap) + " / "
      + StringUtils.byteDesc(maxHeap) + " (" + used + "%). Commited Heap: "
      + StringUtils.byteDesc(commitedHeap) + ". Init Heap: "
      + StringUtils.byteDesc(initHeap) + ". <br>";
  str += " Non Heap Memory Size is " + StringUtils.byteDesc(totalNonHeap)
      + " / " + StringUtils.byteDesc(maxNonHeap)
      + " (" + usedNonHeap + "%). Commited Non Heap: "
      + StringUtils.byteDesc(commitedNonHeap) + ".<br>";
  return str;
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:40,代码来源:JspHelper.java


注:本文中的java.lang.management.MemoryMXBean.getNonHeapMemoryUsage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。