Package java.lang.management

Examples of java.lang.management.MemoryMXBean


  volatile Object guard;
 
  // This shows an easy stack overflow because we're counting recursively.
  public void testLargeSetOfByteArrays() {
    MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();

    causeGc();
    long before = memoryMXBean.getHeapMemoryUsage().getUsed();
    Object [] all = new Object [1000000];
    for (int i = 0; i < all.length; i++) {
      all[i] = new byte[random().nextInt(3)];
    }
    causeGc();
    long after = memoryMXBean.getHeapMemoryUsage().getUsed();
    System.out.println("mx:  " + RamUsageEstimator.humanReadableUnits(after - before));
    System.out.println("rue: " + RamUsageEstimator.humanReadableUnits(shallowSizeOf(all)));

    guard = all;
  }
View Full Code Here


    }
    return s;
  }

  public void testSimpleByteArrays() {
    MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();

    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;
        }

View Full Code Here

        return kernel.getBootTime();
    }

    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();
View Full Code Here

    return success;
  }
 
  private void processAllMemoryStats(DatabusRequest request) throws IOException
  {
    MemoryMXBean memStats = ManagementFactory.getMemoryMXBean();
    writeJsonObjectToResponse(memStats, request);
  }
View Full Code Here

 
  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();
View Full Code Here

    final AtomicReference<BlurException> error = new AtomicReference<BlurException>();
    final AtomicBoolean fail = new AtomicBoolean();

    System.gc();
    System.gc();
    MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();
    MemoryUsage usage = memoryMXBean.getHeapMemoryUsage();
    long max = usage.getMax();
    long used = usage.getUsed();
    long limit = (long) (max * 0.80);
    long difference = limit - used;
    byte[] bufferToFillHeap = new byte[(int) (difference - _20MB)];
View Full Code Here

    memstore = new MemStore(conf, KeyValue.COMPARATOR);
   
    int ROW_SIZE = 2048;
    byte[] qualifier = new byte[ROW_SIZE - 4];
   
    MemoryMXBean bean = ManagementFactory.getMemoryMXBean();
    for (int i = 0; i < 3; i++) { System.gc(); }
    long usageBefore = bean.getHeapMemoryUsage().getUsed();
   
    long size = 0;
    long ts=0;
   
    for (int newValue = 0; newValue < 1000; newValue++) {
      for (int row = newValue; row < newValue + 1000; row++) {
        byte[] rowBytes = Bytes.toBytes(row);
        size += memstore.updateColumnValue(rowBytes, FAMILY, qualifier, newValue, ++ts);
      }
    }
    System.out.println("Wrote " + ts + " vals");
    for (int i = 0; i < 3; i++) { System.gc(); }
    long usageAfter = bean.getHeapMemoryUsage().getUsed();
    System.out.println("Memory used: " + (usageAfter - usageBefore)
        + " (heapsize: " + memstore.heapSize() +
        " size: " + size + ")");
  }
View Full Code Here

         String cname = oname.getCanonicalName();
         PlatformMBeanIDC mmidc = new PlatformMBeanIDC(server, oname, mbean);
         mbeans.put(cname, mmidc);
      }
      // MemoryMXBean
      MemoryMXBean mxbean = ManagementFactory.getMemoryMXBean();
      ObjectName mxname = new ObjectName(ManagementFactory.MEMORY_MXBEAN_NAME);
      PlatformMBeanIDC mxidc = new PlatformMBeanIDC(server, mxname, mxbean);
      mbeans.put(mxname.getCanonicalName(), mxidc);
     
      // MemoryPoolMXBeans
View Full Code Here

   * @param iThreshold
   */
  public OMemoryWatchDog(final float iThreshold) {
    OMemoryWatchDog.setPercentageUsageThreshold(iThreshold);

    final MemoryMXBean memBean = ManagementFactory.getMemoryMXBean();

    final NotificationEmitter memEmitter = (NotificationEmitter) memBean;
    memEmitter.addNotificationListener(new NotificationListener() {
      public synchronized void handleNotification(Notification n, Object hb) {
        if (n.getType().equals(MemoryNotificationInfo.MEMORY_THRESHOLD_EXCEEDED)) {
View Full Code Here

   * @param iThreshold
   */
  public OMemoryWatchDog(final float iThreshold) {
    OMemoryWatchDog.setPercentageUsageThreshold(iThreshold);

    final MemoryMXBean memBean = ManagementFactory.getMemoryMXBean();

    final NotificationEmitter memEmitter = (NotificationEmitter) memBean;
    memEmitter.addNotificationListener(new NotificationListener() {
      public void handleNotification(Notification n, Object hb) {
        if (n.getType().equals(MemoryNotificationInfo.MEMORY_THRESHOLD_EXCEEDED)) {
View Full Code Here

TOP

Related Classes of java.lang.management.MemoryMXBean

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.