}
ETuple2 tup;
if (type == am_allocated_areas) {
ECons res = ERT.NIL;
List<MemoryPoolMXBean> bean2 = ManagementFactory
.getMemoryPoolMXBeans();
if (bean2 == null) {
MemoryMXBean bean = ManagementFactory.getMemoryMXBean();
if (bean != null) {
MemoryUsage mu = bean.getHeapMemoryUsage();
res = res.cons(ETuple.make(am_heap, ERT.box(mu.getCommitted()),
ERT.box(mu.getUsed())));
mu = bean.getNonHeapMemoryUsage();
res = res.cons(ETuple.make(am_non_heap, ERT.box(mu
.getCommitted()), ERT.box(mu.getUsed())));
}
return res;
}
for (MemoryPoolMXBean mb : bean2) {
String name = mb.getName();
MemoryUsage mu = mb.getUsage();
if (mu == null) continue;
String name2 = (mb.getType()==MemoryType.HEAP ? "heap:" : "non_heap:" ) + name;
res = res.cons(ETuple.make(EAtom.intern(name2), ERT.box(mu
.getCommitted()), ERT.box(mu.getUsed())));
}