List of usage examples for java.lang Runtime totalMemory
public native long totalMemory();
From source file:Main.java
public static long getUsedMemorySize() { long freeSize = 0L; long totalSize = 0L; long usedSize = -1L; try {/*from w ww . j av a2 s . co m*/ Runtime info = Runtime.getRuntime(); freeSize = info.freeMemory(); totalSize = info.totalMemory(); usedSize = totalSize - freeSize; } catch (Exception e) { e.printStackTrace(); } return usedSize / 1048576L; }
From source file:Main.java
public static long getPhysicalMemorySize() { long freeSize = 0L; long totalSize = 0L; long usedSize = -1L; try {/* w w w .j a va 2 s . c o m*/ Runtime info = Runtime.getRuntime(); freeSize = info.freeMemory(); totalSize = info.totalMemory(); usedSize = totalSize - freeSize; } catch (Exception e) { e.printStackTrace(); } return totalSize / 1048576L; }
From source file:com.talis.entity.TestUtils.java
public static void showMemory() { Runtime r = Runtime.getRuntime(); long bytes = r.totalMemory() - r.freeMemory(); System.out.println(String.format("Memory usage : %s (%s)", FileUtils.byteCountToDisplaySize(bytes), bytes)); }
From source file:Util.java
/** * Returns a report of used and available memory. * //from w ww . j a v a 2 s . c o m * @return a report of used and available memory */ @SuppressWarnings("boxing") public static String memoryReport() { Runtime runtime = Runtime.getRuntime(); long freemem = runtime.freeMemory(); long totalmem = runtime.totalMemory(); return String.format( "%.1f MB of memory free out of %.1f MB total in JVM (%.1f MB used). Configured maximum: %.1f MB.", freemem / BYTES_PER_MB, totalmem / BYTES_PER_MB, (totalmem - freemem) / BYTES_PER_MB, runtime.maxMemory() / BYTES_PER_MB); }
From source file:org.codelibs.fess.util.MemoryUtil.java
public static long getUsedMemory() { final Runtime runtime = Runtime.getRuntime(); final long freeBytes = runtime.freeMemory(); final long totalBytes = runtime.totalMemory(); return totalBytes - freeBytes; }
From source file:ee.ria.xroad.proxy.opmonitoring.OpMonitoringBufferMemoryUsage.java
private static long getUsedBytes(Runtime runtime) { return runtime.totalMemory() - runtime.freeMemory(); }
From source file:net.ymate.platform.commons.util.RuntimeUtils.java
/** * //from w ww .ja v a 2 s.co m * * @return ?? */ public static final long gc() { Runtime rt = Runtime.getRuntime(); long lastUsed = rt.totalMemory() - rt.freeMemory(); rt.gc(); return lastUsed - rt.totalMemory() + rt.freeMemory(); }
From source file:org.codelibs.fess.util.MemoryUtil.java
public static String getMemoryUsageLog() { final Runtime runtime = Runtime.getRuntime(); final long freeBytes = runtime.freeMemory(); final long maxBytes = runtime.maxMemory(); final long totalBytes = runtime.totalMemory(); final long usedBytes = totalBytes - freeBytes; return "Mem:{used " + byteCountToDisplaySize(usedBytes) + ", heap " + byteCountToDisplaySize(totalBytes) + ", max " + byteCountToDisplaySize(maxBytes) + "}"; }
From source file:com.bstek.dorado.console.utils.SystemUtils.java
/** * ??// www. j a v a 2 s . c o m * * @return */ public static Map<String, Object> getMemoryInfo() { Map<String, Object> map = new HashMap<String, Object>(); Runtime runtime = Runtime.getRuntime(); map.put("runtime", runtime); map.put("freeMemory", runtime.freeMemory()); map.put("totalMemory", runtime.totalMemory()); if (System.getProperty("java.version").compareTo("1.4") >= 0) map.put("maxMemory", runtime.maxMemory()); else map.put("maxMemory", "N/A"); map.put("CPU", runtime.availableProcessors()); return map; }
From source file:ninja.undertow.Benchmarker.java
static public void logMemory() { //Getting the runtime reference from system Runtime runtime = Runtime.getRuntime(); log.info("##### Heap utilization statistics [MB] #####"); //Print used memory log.info("Used Memory:" + (runtime.totalMemory() - runtime.freeMemory())); //Print free memory log.info("Free Memory:" + runtime.freeMemory()); //Print total available memory log.info("Total Memory:" + runtime.totalMemory()); //Print Maximum available memory log.info("Max Memory:" + runtime.maxMemory()); }