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;
}
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());
}
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;
}
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);
}
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);
}
Aggregations