Search in sources :

Example 21 with MemoryMXBean

use of java.lang.management.MemoryMXBean in project hive by apache.

the class TopNHash method initialize.

public void initialize(int topN, float memUsage, boolean isMapGroupBy, BinaryCollector collector, final OperatorDesc conf, final Configuration hconf) {
    assert topN >= 0 && memUsage > 0;
    assert !this.isEnabled;
    this.isEnabled = false;
    this.topN = topN;
    this.collector = collector;
    if (topN == 0) {
        isEnabled = true;
        // topN == 0 will cause a short-circuit, don't need any initialization
        return;
    }
    final boolean isTez = HiveConf.getVar(hconf, HiveConf.ConfVars.HIVE_EXECUTION_ENGINE).equals("tez");
    final boolean isLlap = isTez && HiveConf.getVar(hconf, HiveConf.ConfVars.HIVE_EXECUTION_MODE).equals("llap");
    final int numExecutors = isLlap ? HiveConf.getIntVar(hconf, HiveConf.ConfVars.LLAP_DAEMON_NUM_EXECUTORS) : 1;
    // Used Memory = totalMemory() - freeMemory();
    // Total Free Memory = maxMemory() - Used Memory;
    long totalFreeMemory = Runtime.getRuntime().maxMemory() - Runtime.getRuntime().totalMemory() + Runtime.getRuntime().freeMemory();
    if (isTez) {
        MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();
        // TODO: For LLAP, assumption is off-heap cache.
        final long memoryUsedPerExecutor = (memoryMXBean.getHeapMemoryUsage().getUsed() / numExecutors);
        // this is total free memory available per executor in case of LLAP
        totalFreeMemory = conf.getMaxMemoryAvailable() - memoryUsedPerExecutor;
    }
    // limit * 64 : compensation of arrays for key/value/hashcodes
    this.threshold = (long) (memUsage * totalFreeMemory) - topN * 64L;
    if (threshold < 0) {
        return;
    }
    this.indexes = isMapGroupBy ? new HashForGroup() : new HashForRow();
    this.keys = new byte[topN + 1][];
    this.values = new byte[topN + 1][];
    this.hashes = new int[topN + 1];
    this.distKeyLengths = new int[topN + 1];
    this.evicted = topN;
    this.isEnabled = true;
}
Also used : MemoryMXBean(java.lang.management.MemoryMXBean)

Example 22 with MemoryMXBean

use of java.lang.management.MemoryMXBean in project gephi by gephi.

the class ReportController method logMemoryInfo.

private void logMemoryInfo(Report report) {
    MemoryMXBean bean = ManagementFactory.getMemoryMXBean();
    report.setHeapMemoryUsage(bean.getHeapMemoryUsage().toString());
    report.setNonHeapMemoryUsage(bean.getNonHeapMemoryUsage().toString());
}
Also used : MemoryMXBean(java.lang.management.MemoryMXBean)

Example 23 with MemoryMXBean

use of java.lang.management.MemoryMXBean in project gocd by gocd.

the class MemoryInformationProvider method asJson.

@Override
public Map<String, Object> asJson() {
    MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();
    LinkedHashMap<String, Object> json = new LinkedHashMap<>();
    json.put("Heap", formatInJson(memoryMXBean.getHeapMemoryUsage()));
    json.put("Non Heap", formatInJson(memoryMXBean.getNonHeapMemoryUsage()));
    json.put("Pending Finalization", memoryMXBean.getObjectPendingFinalizationCount());
    return json;
}
Also used : MemoryMXBean(java.lang.management.MemoryMXBean) LinkedHashMap(java.util.LinkedHashMap)

Example 24 with MemoryMXBean

use of java.lang.management.MemoryMXBean in project hazelcast by hazelcast.

the class TimedMemberStateFactoryHelper method createRuntimeProps.

static void createRuntimeProps(MemberStateImpl memberState) {
    Runtime runtime = Runtime.getRuntime();
    ThreadMXBean threadMxBean = ManagementFactory.getThreadMXBean();
    RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
    ClassLoadingMXBean clMxBean = ManagementFactory.getClassLoadingMXBean();
    MemoryMXBean memoryMxBean = ManagementFactory.getMemoryMXBean();
    MemoryUsage heapMemory = memoryMxBean.getHeapMemoryUsage();
    MemoryUsage nonHeapMemory = memoryMxBean.getNonHeapMemoryUsage();
    Map<String, Long> map = new HashMap<String, Long>();
    map.put("runtime.availableProcessors", Integer.valueOf(runtime.availableProcessors()).longValue());
    map.put("date.startTime", runtimeMxBean.getStartTime());
    map.put("seconds.upTime", runtimeMxBean.getUptime());
    map.put("memory.maxMemory", runtime.maxMemory());
    map.put("memory.freeMemory", runtime.freeMemory());
    map.put("memory.totalMemory", runtime.totalMemory());
    map.put("memory.heapMemoryMax", heapMemory.getMax());
    map.put("memory.heapMemoryUsed", heapMemory.getUsed());
    map.put("memory.nonHeapMemoryMax", nonHeapMemory.getMax());
    map.put("memory.nonHeapMemoryUsed", nonHeapMemory.getUsed());
    map.put("runtime.totalLoadedClassCount", clMxBean.getTotalLoadedClassCount());
    map.put("runtime.loadedClassCount", Integer.valueOf(clMxBean.getLoadedClassCount()).longValue());
    map.put("runtime.unloadedClassCount", clMxBean.getUnloadedClassCount());
    map.put("runtime.totalStartedThreadCount", threadMxBean.getTotalStartedThreadCount());
    map.put("runtime.threadCount", Integer.valueOf(threadMxBean.getThreadCount()).longValue());
    map.put("runtime.peakThreadCount", Integer.valueOf(threadMxBean.getPeakThreadCount()).longValue());
    map.put("runtime.daemonThreadCount", Integer.valueOf(threadMxBean.getDaemonThreadCount()).longValue());
    OperatingSystemMXBean osMxBean = ManagementFactory.getOperatingSystemMXBean();
    map.put("osMemory.freePhysicalMemory", get(osMxBean, "getFreePhysicalMemorySize", 0L));
    map.put("osMemory.committedVirtualMemory", get(osMxBean, "getCommittedVirtualMemorySize", 0L));
    map.put("osMemory.totalPhysicalMemory", get(osMxBean, "getTotalPhysicalMemorySize", 0L));
    map.put("osSwap.freeSwapSpace", get(osMxBean, "getFreeSwapSpaceSize", 0L));
    map.put("osSwap.totalSwapSpace", get(osMxBean, "getTotalSwapSpaceSize", 0L));
    map.put("os.maxFileDescriptorCount", get(osMxBean, "getMaxFileDescriptorCount", 0L));
    map.put("os.openFileDescriptorCount", get(osMxBean, "getOpenFileDescriptorCount", 0L));
    map.put("os.processCpuLoad", get(osMxBean, "getProcessCpuLoad", -1L));
    map.put("os.systemLoadAverage", get(osMxBean, "getSystemLoadAverage", -1L));
    map.put("os.systemCpuLoad", get(osMxBean, "getSystemCpuLoad", -1L));
    map.put("os.processCpuTime", get(osMxBean, "getProcessCpuTime", 0L));
    map.put("os.availableProcessors", get(osMxBean, "getAvailableProcessors", 0L));
    memberState.setRuntimeProps(map);
}
Also used : ThreadMXBean(java.lang.management.ThreadMXBean) MemoryMXBean(java.lang.management.MemoryMXBean) HashMap(java.util.HashMap) ClassLoadingMXBean(java.lang.management.ClassLoadingMXBean) RuntimeMXBean(java.lang.management.RuntimeMXBean) MemoryUsage(java.lang.management.MemoryUsage) OperatingSystemMXBean(java.lang.management.OperatingSystemMXBean)

Example 25 with MemoryMXBean

use of java.lang.management.MemoryMXBean in project databus by linkedin.

the class JavaStatsRequestProcessor method processAllMemoryStats.

private void processAllMemoryStats(DatabusRequest request) throws IOException {
    MemoryMXBean memStats = ManagementFactory.getMemoryMXBean();
    writeJsonObjectToResponse(memStats, request);
}
Also used : MemoryMXBean(java.lang.management.MemoryMXBean)

Aggregations

MemoryMXBean (java.lang.management.MemoryMXBean)38 MemoryUsage (java.lang.management.MemoryUsage)13 RuntimeMXBean (java.lang.management.RuntimeMXBean)10 GarbageCollectorMXBean (java.lang.management.GarbageCollectorMXBean)7 ThreadMXBean (java.lang.management.ThreadMXBean)7 OperatingSystemMXBean (java.lang.management.OperatingSystemMXBean)6 ClassLoadingMXBean (java.lang.management.ClassLoadingMXBean)5 MemoryPoolMXBean (java.lang.management.MemoryPoolMXBean)5 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 Properties (java.util.Properties)3 NotificationEmitter (javax.management.NotificationEmitter)2 ObjectName (javax.management.ObjectName)2 MetricGroup (org.apache.flink.metrics.MetricGroup)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 Function (com.google.common.base.Function)1 Description (com.google.gerrit.metrics.Description)1 UnixOperatingSystemMXBean (com.sun.management.UnixOperatingSystemMXBean)1