當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。