Package java.lang.management

Examples of java.lang.management.MemoryUsage


   * @return Usage of the perm gen space.
   */
  private double getPermGenUsage() {
    for (MemoryPoolMXBean item : ManagementFactory.getMemoryPoolMXBeans()) {
      if (item.getName().contains("Perm Gen")) {
        MemoryUsage usage = item.getUsage();
        return usage.getUsed() / (double) usage.getCommitted();
      }
    }
   
    // Unknown
    return 0;
View Full Code Here


    Object [][] all = new Object [0][];
    try {
      while (true) {
        // Check the current memory consumption and provide the estimate.
        causeGc();
        MemoryUsage mu = memoryMXBean.getHeapMemoryUsage();
        long estimated = shallowSizeOf(all);
        if (estimated > 50 * RamUsageEstimator.ONE_MB) {
          break;
        }

        System.out.println(String.format(Locale.ROOT, "%10s\t%10s\t%10s",
            RamUsageEstimator.humanReadableUnits(mu.getUsed()),
            RamUsageEstimator.humanReadableUnits(mu.getMax()),
            RamUsageEstimator.humanReadableUnits(estimated)));

        // Make another batch of objects.
        Object[] seg =  new Object[10000];
        all = Arrays.copyOf(all, all.length + 1);
View Full Code Here

        // Uptime
        long secondsUp = probe.getUptime() / 1000;
        outs.printf("%-17s: %d%n", "Uptime (seconds)", secondsUp);

        // Memory usage
        MemoryUsage heapUsage = probe.getHeapMemoryUsage();
        double memUsed = (double)heapUsage.getUsed() / (1024 * 1024);
        double memMax = (double)heapUsage.getMax() / (1024 * 1024);
        outs.printf("%-17s: %.2f / %.2f%n", "Heap Memory (MB)", memUsed, memMax);

        // Data Center/Rack
        outs.printf("%-17s: %s%n", "Data Center", probe.getDataCenter());
        outs.printf("%-17s: %s%n", "Rack", probe.getRack());
View Full Code Here

    }

    public Stats getStats() {
        RuntimeMXBean runmxbean = ManagementFactory.getRuntimeMXBean();
        MemoryMXBean memmxbean = ManagementFactory.getMemoryMXBean();
        MemoryUsage memUsage = memmxbean.getHeapMemoryUsage();
        CountStatisticImpl upTime;
        BoundedRangeStatisticImpl heapSize;

        if (stats == null) {
            stats = new JVMStatsImpl();
            // setup UpTime CountStatistic
            upTime = stats.getUpTimeImpl();
            upTime.setStartTime(runmxbean.getStartTime());
            upTime.setCount(runmxbean.getUptime());
            // setup Heap BoundedRangeStatistic
            heapSize = stats.getHeapSizeImpl();
            heapSize.setStartTime(runmxbean.getStartTime());
            heapSize.setBounds(0, memUsage.getMax());
            heapSize.setCurrent(memUsage.getUsed());
            heapSize.setLowWaterMark(memUsage.getUsed());
            heapSize.setHighWaterMark(memUsage.getUsed());
        } else {
            // update UpTime CountStatistic
            upTime = stats.getUpTimeImpl();
            upTime.setCount(runmxbean.getUptime());
            // update Heap BoundedRangeStatistic
            heapSize = stats.getHeapSizeImpl();
            heapSize.setBounds(0, memUsage.getMax());
            heapSize.setCurrent(memUsage.getUsed());
        }
        long now = upTime.getStartTime() + upTime.getCount();
        upTime.setLastSampleTime(now);
        heapSize.setLastSampleTime(now);
View Full Code Here

        public MemoryStats(MemoryPoolMXBean memoryBean) {
            this.memoryBean = memoryBean;
        }

        public boolean isUsageThresholdExceeded(int threshold) {
            MemoryUsage memoryUsage = getMemoryUsage();
            return memoryUsage != null && memoryUsage.getUsed() * 100 / memoryUsage.getMax() >= threshold;
        }
View Full Code Here

    writeJsonObjectToResponse(gcStats, request);
  }

  private void processNonHeapMemoryStats(DatabusRequest request) throws IOException
  {
    MemoryUsage memStats = ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage();
    writeJsonObjectToResponse(memStats, request);
  }
View Full Code Here

    writeJsonObjectToResponse(memStats, request);
  }

  private void processHeapMemoryStats(DatabusRequest request) throws IOException
  {
    MemoryUsage memStats = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
    writeJsonObjectToResponse(memStats, request);
  }
View Full Code Here

    // Instead they should be stored in an HBase table so that external visibility into HBase is
    // improved; Additionally the load balancer will be able to take advantage of a more complete
    // history.
    MetricsRegionServerWrapper regionServerWrapper = this.metricsRegionServer.getRegionServerWrapper();
    Collection<HRegion> regions = getOnlineRegionsLocalContext();
    MemoryUsage memory =
      ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();

    ClusterStatusProtos.ServerLoad.Builder serverLoad =
      ClusterStatusProtos.ServerLoad.newBuilder();
    serverLoad.setNumberOfRequests((int) regionServerWrapper.getRequestsPerSecond());
    serverLoad.setTotalNumberOfRequests((int) regionServerWrapper.getTotalRequestCount());
    serverLoad.setUsedHeapMB((int)(memory.getUsed() / 1024 / 1024));
    serverLoad.setMaxHeapMB((int) (memory.getMax() / 1024 / 1024));
    Set<String> coprocessors = this.hlog.getCoprocessorHost().getCoprocessors();
    for (String coprocessor : coprocessors) {
      serverLoad.addCoprocessors(
        Coprocessor.newBuilder().setName(coprocessor).build());
    }
View Full Code Here

        // we have something to tell (and we didn't just fail sending master).
        if ((now - lastMsg) >= msgInterval ||
            ((outboundArray == null || outboundArray.length == 0) && !this.outboundMsgs.isEmpty())) {
          try {
            doMetrics();
            MemoryUsage memory =
              ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
            HServerLoad hsl = new HServerLoad(requestCount.get(),
              (int)(memory.getUsed()/1024/1024),
              (int)(memory.getMax()/1024/1024));
            for (HRegion r: onlineRegions.values()) {
              hsl.addRegionInfo(createRegionLoad(r));
            }
            this.serverInfo.setLoad(hsl);
            this.requestCount.set(0);
View Full Code Here

    MapWritable result = null;
    long lastMsg = 0;
    while(!stopRequested.get()) {
      try {
        this.requestCount.set(0);
        MemoryUsage memory =
          ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
        HServerLoad hsl = new HServerLoad(0, (int)memory.getUsed()/1024/1024,
          (int)memory.getMax()/1024/1024);
        this.serverInfo.setLoad(hsl);
        if (LOG.isDebugEnabled())
          LOG.debug("sending initial server load: " + hsl);
        lastMsg = System.currentTimeMillis();
        boolean startCodeOk = false;
View Full Code Here

TOP

Related Classes of java.lang.management.MemoryUsage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.