void (String path) { MemoryCapture capture = MemoryCapture.capture(); MemoryMetrics memory = new MemoryMetrics(capture.getUsedMb(), capture.getMaxMb(), capture.getMetaspaceMb()); ExitMetrics metrics = new ExitMetrics(memory); try { new ObjectMapper().writeValue(new File(path), metrics); } catch (IOException e) { //noinspection UseOfSystemOutOrSystemErr System.err.println("Unable to write exit metrics from " + ExitAppCommand.class.getSimpleName() + " " + e.getMessage()); } }