Examples of MemoryPoolMXBean


Examples of java.lang.management.MemoryPoolMXBean

            final int len = indexes.length;
            final Map<String, SnmpOid> m = new HashMap<String, SnmpOid>(len);
            for (int i=0; i<len; i++) {
                final SnmpOid index = indexes[i];
                if (index == null) continue;
                final MemoryPoolMXBean mpm =
                    (MemoryPoolMXBean)datas[i];
                if (mpm == null) continue;
                final String name = mpm.getName();
                if (name == null) continue;
                m.put(name,index);
            }
            return m;
        }
View Full Code Here

Examples of java.lang.management.MemoryPoolMXBean

        }

        final SnmpCachedData data = (SnmpCachedData)handler;
        final int len = data.datas.length;
        for (int i=0; i < data.datas.length ; i++) {
            final MemoryPoolMXBean pool = (MemoryPoolMXBean) data.datas[i];
            if (poolName.equals(pool.getName())) return i;
        }
        return -1;
    }
View Full Code Here

Examples of java.lang.management.MemoryPoolMXBean

        }

        // check if memory usage for all memory pools are returned
        List pools = ManagementFactory.getMemoryPoolMXBeans();
        for (Iterator iter = pools.iterator(); iter.hasNext(); ) {
            MemoryPoolMXBean p = (MemoryPoolMXBean) iter.next();
            if (!pnames.contains(p.getName())) {
                throw new RuntimeException("GcInfo does not contain " +
                    "memory usage for pool " + p.getName());
            }
        }
    }
View Full Code Here

Examples of java.lang.management.MemoryPoolMXBean

            ObjectName gcName = new ObjectName(ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE+",*");
            Set mbeans = mbsc.queryNames(poolName, null);
            if (mbeans != null) {
                pools = new ArrayList<MemoryPoolMXBean>();
                Iterator iterator = mbeans.iterator();
                MemoryPoolMXBean p = null;
                    while (iterator.hasNext()) {
                        ObjectName objName = (ObjectName) iterator.next();
                        p = ManagementFactory.newPlatformMXBeanProxy(mbsc,
                                                   objName.getCanonicalName(),
                                                   MemoryPoolMXBean.class);
View Full Code Here

Examples of java.lang.management.MemoryPoolMXBean

    private void addPermGenStatistics(List states)
    {
      Iterator iter1 = ManagementFactory.getMemoryPoolMXBeans().iterator();
      while (iter1.hasNext())
      {
          MemoryPoolMXBean item = (MemoryPoolMXBean) iter1.next();
          long used = item.getUsage().getUsed() / 1024 / 1024;
          long max = item.getUsage().getMax() / 1024 / 1024;
          long usedDivided = used;
          long maxDivided = max;
          if(max > 100)
          {
            usedDivided = used / 10;
            maxDivided = max / 10;
          }
         
          states.add(getList("" + item.getName(), "" + used + " / " + max + "<div style='border: 1px solid #ccc; background-color: green; height: 10px; width: " + maxDivided + "px;'><div style='margin-top: 2px; background-color: red; height: 6px; width: " + usedDivided + "px;'></div></div>"));
     
     
      long max = Runtime.getRuntime().maxMemory() / 1024 / 1024;
      long used = ((Runtime.getRuntime().totalMemory()- Runtime.getRuntime().freeMemory()) / 1024 / 1024);
      long usedDivided = used;
View Full Code Here

Examples of java.lang.management.MemoryPoolMXBean

    private static boolean messageDelivered = false;

    public void startup() {
        ((NotificationEmitter) ManagementFactory.getMemoryMXBean()).addNotificationListener(this, null, null);
        List<MemoryPoolMXBean> mpbeans = ManagementFactory.getMemoryPoolMXBeans();
        MemoryPoolMXBean biggestHeap = null;
        long biggestSize = 0;
        for (MemoryPoolMXBean b : mpbeans) {
            if (b.getType() == MemoryType.HEAP) {
                /* Here we are making the leap of faith that the biggest
                 * heap is the tenured heap
                 */
                long size = b.getUsage().getMax();
                if (size > biggestSize) {
                    biggestSize = size;
                    biggestHeap = b;
                }
            }
        }
        if (biggestHeap != null) {
            long usageThreshold = (long) (biggestSize - reservedMemory);
            biggestHeap.setUsageThreshold(usageThreshold);
            biggestHeap.setCollectionUsageThreshold(usageThreshold);
        }
    }
View Full Code Here

Examples of java.lang.management.MemoryPoolMXBean

            @Override
            public Row next() {
                if(!it.hasNext()) {
                    return null;
                }
                MemoryPoolMXBean pool = it.next();
                return new ValuesRow(rowType,
                                      pool.getName(),
                                      pool.getType().name(),
                                      pool.getUsage().getUsed(),
                                      pool.getUsage().getMax(),
                                      pool.getPeakUsage().getUsed(),
                                      ++rowCounter);
            }
View Full Code Here

Examples of java.lang.management.MemoryPoolMXBean

            return;
        }

        // Hack to work around bugs in java 7 related to code cache management.
        // See http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/2013-August/011333.html for more info.
        final MemoryPoolMXBean codeCacheMbean = findCodeCacheMBean();

        Thread gcThread = new Thread(new Runnable()
        {
            @SuppressWarnings("CallToSystemGC")
            @Override
            public void run()
            {
                Logger log = Logger.get("Code-Cache-GC-Trigger");

                while (!Thread.currentThread().isInterrupted()) {
                    long used = codeCacheMbean.getUsage().getUsed();
                    long max = codeCacheMbean.getUsage().getMax();

                    if (used > 0.95 * max) {
                        log.error("Code Cache is more than 95% full. JIT may stop working.");
                    }
                    if (used > 0.7 * max) {
View Full Code Here

Examples of java.lang.management.MemoryPoolMXBean

            return;
        }

        // Hack to work around bugs in java 7 related to code cache management.
        // See http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/2013-August/011333.html for more info.
        final MemoryPoolMXBean codeCacheMbean = findCodeCacheMBean();
        Preconditions.checkNotNull(codeCacheMbean, "Could not obtain a reference to the 'Code Cache' MemoryPoolMXBean");

        Thread gcThread = new Thread(new Runnable()
        {
            @SuppressWarnings("CallToSystemGC")
            @Override
            public void run()
            {
                Logger log = Logger.get("Code-Cache-GC-Trigger");

                while (!Thread.currentThread().isInterrupted()) {
                    long used = codeCacheMbean.getUsage().getUsed();
                    long max = codeCacheMbean.getUsage().getMax();
                    if (used > 0.7 * max) {
                        // Due to some obscure bug in hotspot (java 7), once the code cache fills up the JIT stops compiling and never recovers from this condition.
                        // By forcing classes to unload from the perm gen, we let the code cache evictor make room before the cache fills up.
                        // For best results, the server should be run with -XX:+UseConcMarkSweepGC -XX:+ExplicitGCInvokesConcurrent -XX:+CMSClassUnloadingEnabled
                        log.info("Triggering GC to avoid Code Cache eviction bugs");
View Full Code Here

Examples of java.lang.management.MemoryPoolMXBean

    private static SpillableMemoryManager manager;

    private SpillableMemoryManager() {
        ((NotificationEmitter)ManagementFactory.getMemoryMXBean()).addNotificationListener(this, null, null);
        List<MemoryPoolMXBean> mpbeans = ManagementFactory.getMemoryPoolMXBeans();
        MemoryPoolMXBean biggestHeap = null;
        long biggestSize = 0;
        long totalSize = 0;
        for (MemoryPoolMXBean b: mpbeans) {
            log.debug("Found heap (" + b.getName() +
                ") of type " + b.getType());
            if (b.getType() == MemoryType.HEAP) {
                /* Here we are making the leap of faith that the biggest
                 * heap is the tenured heap
                 */
                long size = b.getUsage().getMax();
                totalSize += size;
                if (size > biggestSize) {
                    biggestSize = size;
                    biggestHeap = b;
                }
            }
        }
        extraGCSpillSizeThreshold  = (long) (totalSize * extraGCThresholdFraction);
        if (biggestHeap == null) {
            throw new RuntimeException("Couldn't find heap");
        }
        log.debug("Selected heap to monitor (" +
            biggestHeap.getName() + ")");
       
        // we want to set both collection and usage threshold alerts to be
        // safe. In some local tests after a point only collection threshold
        // notifications were being sent though usage threshold notifications
        // were sent early on. So using both would ensure that
        // 1) we get notified early (though usage threshold exceeded notifications)
        // 2) we get notified always when threshold is exceeded (either usage or
        //    collection)
       
        /* We set the threshold to be 50% of tenured since that is where
         * the GC starts to dominate CPU time according to Sun doc */
        biggestHeap.setCollectionUsageThreshold((long)(biggestSize * collectionMemoryThresholdFraction));
        // we set a higher threshold for usage threshold exceeded notification
        // since this is more likely to be effective sooner and we do not
        // want to be spilling too soon
        biggestHeap.setUsageThreshold((long)(biggestSize * memoryThresholdFraction));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.