void (OperatingSystem os, GlobalMemory memory) { OSProcess myProc = os.getProcess(os.getProcessId()); if (myProc == null) { return; } info.add( "My PID: " + myProc.getProcessID() + " with affinity " + Long.toBinaryString(myProc.getAffinityMask())); info.add("Processes: " + os.getProcessCount() + ", Threads: " + os.getThreadCount()); // Sort by highest CPU List<OSProcess> procs = os.getProcesses(OperatingSystem.ProcessFiltering.ALL_PROCESSES, OperatingSystem.ProcessSorting.CPU_DESC, 5); info.add(" PID %CPU %MEM VSZ RSS Name"); for (int i = 0; i < procs.size() && i < 5; i++) { OSProcess p = procs.get(i); info.add(String.format(" %5d %5.1f %4.1f %9s %9s %s", p.getProcessID(), 100d * (p.getKernelTime() + p.getUserTime()) / p.getUpTime(), 100d * p.getResidentSetSize() / memory.getTotal(), FormatUtil.formatBytes(p.getVirtualSize()), FormatUtil.formatBytes(p.getResidentSetSize()), p.getName())); } OSProcess p = os.getProcess(os.getProcessId()); info.add("Current process environment: "); for (Map.Entry<String, String> e : p.getEnvironmentVariables().entrySet()) { info.add(" " + e.getKey() + "=" + e.getValue()); } }