List of utility methods to do Memory
void | removeSliceFromMemory(String schemaName, String cubeName, String loadName) remove Slice From Memory |
void | reportMemory() report Memory Runtime runtime = Runtime.getRuntime(); long mb = 1024 * 1024; long used = runtime.totalMemory() - runtime.freeMemory(); System.out.printf("......................... memory in use: %d MB .........................%n", used / mb); |
String | reportMemory(double val) report Memory val /= 1024; return String.format(" %.4f KB | %.4f MB | %.4f GB", val, val / 1024, val / 1024 / 1024); |
String | simpleMemory() Return the memory in a simple format. StringBuilder memory = new StringBuilder(); Runtime runtime = Runtime.getRuntime(); long maxMemory = runtime.maxMemory(); long totalMemory = runtime.totalMemory(); long freeMemory = runtime.freeMemory(); long usedMemory = totalMemory - freeMemory; memory.append(toSimpleBytes(usedMemory)); memory.append("/"); ... |
boolean | testMemory(long bytesToTest) test Memory System.gc(); if (System.getProperties().getProperty("os.name").startsWith("Windows")) { Runtime r = Runtime.getRuntime(); long avail = r.maxMemory() - r.totalMemory() + r.freeMemory(); return (avail >= bytesToTest); int MEGABYTE = 1048576; int maximumMeg = (int) Math.ceil(bytesToTest / (double) MEGABYTE); ... |
void | throwOutOfMemoryError() throw Out Of Memory Error throw new OutOfMemoryError("java"); |
void | unlimitMemory() unlimit Memory try { String[] cmd = { "/bin/sh", "-c", "ulimit -s unlimited" }; Process proc = Runtime.getRuntime().exec(cmd); proc.waitFor(); } catch (Exception e) { System.err.println("Wrong"); |
void | waitForMemory(double memory) Wait till the given requested amount of MegaBytes is free in memory long memoryInBytes = ConvertMegaByteToByte(memory); while (Runtime.getRuntime().freeMemory() < memoryInBytes) { System.gc(); try { Thread.sleep(500); } catch (InterruptedException e1) { e1.printStackTrace(); |
void | writeMemory() write Memory Runtime rt = Runtime.getRuntime(); System.out.println("Total " + rt.totalMemory() + "\tMax " + rt.maxMemory() + "\tFree " + rt.freeMemory()); |