Skip to content

Instantly share code, notes, and snippets.

@CodingFabian
Last active August 29, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CodingFabian/f0fa87805fe86990d0d0 to your computer and use it in GitHub Desktop.
Save CodingFabian/f0fa87805fe86990d0d0 to your computer and use it in GitHub Desktop.
Setting MaxMetaspaceSize
Non-Heap: init = 2555904(2496K) used = 4508544(4402K) committed = 8060928(7872K) max = 1862270976(1818624K)
Code Cache: init = 2555904(2496K) used = 1199936(1171K) committed = 2555904(2496K) max = 251658240(245760K)
Metaspace: init = 0(0K) used = 3026816(2955K) committed = 4980736(4864K) max = 536870912(524288K)
Compressed Class Space: init = 0(0K) used = 327832(320K) committed = 524288(512K) max = 1073741824(1048576K)
PS Eden Space: init = 67108864(65536K) used = 4026744(3932K) committed = 67108864(65536K) max = 1409286144(1376256K)
PS Survivor Space: init = 11010048(10752K) used = 0(0K) committed = 11010048(10752K) max = 11010048(10752K)
PS Old Gen: init = 179306496(175104K) used = 0(0K) committed = 179306496(175104K) max = 2863661056(2796544K)
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryMXBean;
import java.lang.management.MemoryPoolMXBean;
import java.lang.management.MemoryUsage;
import java.util.List;
public class Tester {
public static void main(String[] args) throws Exception {
MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();
MemoryUsage nonHeapMemoryUsage = memoryMXBean.getNonHeapMemoryUsage();
System.out.println("Non-Heap: " + nonHeapMemoryUsage);
List<MemoryPoolMXBean> memoryPoolMXBeans = ManagementFactory.getMemoryPoolMXBeans();
for (MemoryPoolMXBean memoryPoolMXBean : memoryPoolMXBeans) {
System.out.println(memoryPoolMXBean.getName() + ": " + memoryPoolMXBean.getUsage());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment