List of usage examples for java.lang.management ManagementFactory getMemoryMXBean
public static MemoryMXBean getMemoryMXBean()
From source file:com.chinamobile.bcbsp.comm.RPCSingleSendSlave.java
/** Run method of Thread. */ public void run() { while (true) { while (this.idle) { if (this.completed) { return; }//from ww w.j a va 2s . c o m if (this.noMoreMessagesFlag) { this.superStepCounter++; this.noMoreMessagesFlag = false; } try { Thread.sleep(this.sleepTime); } catch (InterruptedException e) { LOG.error("[RPCSingleSendSlave] to " + this.hostNameAndPort + " has been interrupted for ", e); return; } } if (this.hostNameAndPort == null) { LOG.error("Destination hostname is null."); return; } if (this.messageQueue == null) { LOG.error("Message queue for ProducerTool is null."); return; } this.messageCount = 0; this.connectTime = 0; this.sendTime = 0; while (true) { if (this.reconnectCount == RPCSingleSendSlave.RECONNECTTHRESHOLD) { break; } try { if (this.newHostNameAndPort) { // Should create new connection if (senderProtocol != null) { LOG.info("Sender RPC protocol is not null."); } else { LOG.info("Sender RPC protocol is null and it will instanced now."); } long start = System.currentTimeMillis(); String[] tmp = this.hostNameAndPort.split(":"); String hostname = tmp[0]; int portNum = Integer.parseInt(tmp[1]); this.senderProtocol = (RPCCommunicationProtocol) RPC.waitForProxy( RPCCommunicationProtocol.class, RPCCommunicationProtocol.protocolVersion, new InetSocketAddress(hostname, portNum), new Configuration()); this.connectTime += (System.currentTimeMillis() - start); this.newHostNameAndPort = false; } // Start sending messages this.sendPacked(); this.idle = true; break; } catch (Exception e) { this.reconnectCount++; if (this.reconnectCount == 1) { LOG.error("[SingRPCSendSlave] to " + this.hostNameAndPort + " caught: ", e); } LOG.info("[SingRPCSendSlave] to " + this.hostNameAndPort + " is reconnecting for " + this.reconnectCount + "th time."); LOG.info("---------------- Memory Info ------------------"); MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean(); MemoryUsage memoryUsage = memoryMXBean.getHeapMemoryUsage(); long used = memoryUsage.getUsed(); long committed = memoryUsage.getCommitted(); LOG.info("[JVM Memory used] = " + used / MB_SIZE + "MB"); LOG.info("[JVM Memory committed] = " + committed / MB_SIZE + "MB"); LOG.info("-----------------------------------------------"); try { Thread.sleep(this.sleepTime); } catch (InterruptedException e1) { LOG.error("[SingRPCSendSlave] caught: ", e1); } } } LOG.info("[SingRPCSendSlave] to " + this.hostNameAndPort + " has sent " + this.messageCount + " messages totally! (with " + this.messageQueue.size() + " messages lost!)"); this.sender.addConnectTime(this.connectTime); /* Clock */ this.sender.addSendTime(this.sendTime); if (this.reconnectCount == RPCSingleSendSlave.RECONNECTTHRESHOLD) { LOG.info("[ProducerTool] to " + this.hostNameAndPort + " has reconnected for " + this.reconnectCount + " times but failed!"); this.isFailed = true; break; } } }
From source file:com.android.tools.idea.diagnostics.crash.GoogleCrash.java
@NotNull private static Map<String, String> getDefaultParameters() { Map<String, String> map = new HashMap<>(); ApplicationInfo applicationInfo = getApplicationInfo(); if (ANONYMIZED_UID != null) { map.put("guid", ANONYMIZED_UID); }//from www . j av a 2 s. c o m RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean(); map.put("ptime", Long.toString(runtimeMXBean.getUptime())); // product specific key value pairs map.put(KEY_VERSION, applicationInfo == null ? "0.0.0.0" : applicationInfo.getStrictVersion()); map.put(KEY_PRODUCT_ID, CrashReport.PRODUCT_ANDROID_STUDIO); // must match registration with Crash map.put("fullVersion", applicationInfo == null ? "0.0.0.0" : applicationInfo.getFullVersion()); map.put("osName", StringUtil.notNullize(SystemInfo.OS_NAME)); map.put("osVersion", StringUtil.notNullize(SystemInfo.OS_VERSION)); map.put("osArch", StringUtil.notNullize(SystemInfo.OS_ARCH)); map.put("locale", StringUtil.notNullize(LOCALE)); map.put("vmName", StringUtil.notNullize(runtimeMXBean.getVmName())); map.put("vmVendor", StringUtil.notNullize(runtimeMXBean.getVmVendor())); map.put("vmVersion", StringUtil.notNullize(runtimeMXBean.getVmVersion())); MemoryUsage usage = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage(); map.put("heapUsed", Long.toString(usage.getUsed())); map.put("heapCommitted", Long.toString(usage.getCommitted())); map.put("heapMax", Long.toString(usage.getMax())); return map; }
From source file:fr.tpt.atlanalyser.examples.ExampleRunner.java
public void executePost2Pre(File postFile, int maxNumRuleIterations) throws IOException { // checkDirs(); inputMM = getInputMMEPkg();/* ww w . j a v a 2s .c o m*/ outputMM = getOutputMMEPkg(); makeAbstractClassesInstantiable(inputMM); makeAbstractClassesInstantiable(outputMM); Module transfo = loadHenshinTransformation(); EcoreUtil.resolveAll(transfo); EPackage traceMM = resourceSet.getPackageRegistry().getEPackage("http://traces/1.0"); stripFromAttributes(transfo); Resource postRes = resourceSet.getResource(URI.createFileURI(postFile.getCanonicalPath()), true); Module postModule = (Module) postRes.getContents().get(0); EList<Unit> units = postModule.getUnits(); List<Formula> postconditions = Lists.transform(units, new Function<Unit, Formula>() { @Override public Formula apply(Unit arg0) { return ((Rule) arg0).getLhs().getFormula(); } }); Module preModule = HenshinFactory.eINSTANCE.createModule(); preModule.setName("Preconditions"); LOGGER.info("Starting Post2Pre for {}", transfo.getName()); Post2Pre4ATL post2Pre = new Post2Pre4ATL(transfo, inputMM, outputMM, traceMM, jobs); ScheduledExecutorService memMonitorExecutor = Executors.newScheduledThreadPool(1); memMonitorExecutor.scheduleAtFixedRate(new Runnable() { private final MemoryMXBean memoryBean = ManagementFactory.getMemoryMXBean(); private final Logger LOGGER = LogManager.getLogger("MemMon"); @Override public void run() { // LOGGER.setAdditivity(false); // for (Enumeration iterator = // AGGWrapper.LOGGER.getAllAppenders(); iterator // .hasMoreElements();) { // Appender appender = (Appender) iterator.nextElement(); // LOGGER.addAppender(appender); // } MemoryUsage heapUsage = memoryBean.getHeapMemoryUsage(); final long used = heapUsage.getUsed(); double usedGB = (double) used / (1 << 30); final long max = heapUsage.getMax(); double maxGB = (double) max / (1 << 30); LOGGER.info(String.format("Memory use : %6.3fGB of %6.3fGB (%.2f%%)", usedGB, maxGB, (float) used / max * 100)); } }, 0, 10, TimeUnit.SECONDS); try { for (Formula formula : postconditions) { Formula pre = post2Pre.post2Pre(formula, maxNumRuleIterations); Rule preRule = HenshinFactory.eINSTANCE.createRule(); Graph preLhs = HenshinFactory.eINSTANCE.createGraph(); preLhs.setFormula(EcoreUtil.copy(pre)); preRule.setLhs(preLhs); preModule.getUnits().add(preRule); } } finally { memMonitorExecutor.shutdown(); } File outputDir = new File(baseDir, "Preconditions"); if (!outputDir.isDirectory()) { outputDir.mkdir(); } Resource outputRes = resourceSet .createResource(URI.createFileURI("Preconditions/" + postFile.getName() + "_pre.henshin")); outputRes.getContents().add(preModule); LOGGER.info("Writing Precondition in {}", outputRes.getURI().toString()); outputRes.save(xmiSaveOptions); LOGGER.info("Done!"); }
From source file:com.chinamobile.bcbsp.comm.MessageQueuesForDisk.java
/** * Constructor.//from w w w . ja va 2 s .c o m * @param job * @param partitionID */ public MessageQueuesForDisk(BSPJob job, int partitionID) { LOG.info("========== Initializing Message Queues Data For Disk =========="); this.dataPercent = job.getMemoryDataPercent(); // Default 0.8 this.jobID = job.getJobID(); this.partitionID = partitionID; // ratio of graph data this.beta = job.getBeta(); this.hashBucketNumber = job.getHashBucketNumber(); LOG.info("[beta] = " + this.beta); LOG.info("[hashBucketNumber] = " + this.hashBucketNumber); // the structure of three kinds message queues this.outgoingQueues = new ConcurrentHashMap<String, ConcurrentLinkedQueue<IMessage>>(); this.incomingQueues = new ArrayList<BucketMeta>(this.hashBucketNumber); this.incomedQueues = new ArrayList<BucketMeta>(this.hashBucketNumber); for (int i = 0; i < this.hashBucketNumber; i++) { BucketMeta meta = new BucketMeta(); meta.onDiskFlag = false; meta.length = 0; meta.lengthInMemory = 0; meta.count = 0; meta.countInMemory = 0; meta.queueMap = new ConcurrentHashMap<String, ConcurrentLinkedQueue<IMessage>>(); this.incomingQueues.add(meta); meta = new BucketMeta(); meta.onDiskFlag = false; meta.length = 0; meta.lengthInMemory = 0; meta.count = 0; meta.countInMemory = 0; meta.queueMap = new ConcurrentHashMap<String, ConcurrentLinkedQueue<IMessage>>(); this.incomedQueues.add(meta); } // Initialize the bucket file locks this.incomedFileLocks = new ReentrantLock[this.hashBucketNumber]; this.incomingFileLocks = new ReentrantLock[this.hashBucketNumber]; for (int i = 0; i < this.hashBucketNumber; i++) { this.incomedFileLocks[i] = new ReentrantLock(); this.incomingFileLocks[i] = new ReentrantLock(); } // Initialize the size of objects. BSPConfiguration conf = new BSPConfiguration(); if (conf.getInt(Constants.BC_BSP_JVM_VERSION, 32) == 64) { sizer = ObjectSizer.forSun64BitsVM(); } else { sizer = ObjectSizer.forSun32BitsVM(); } this.sizeOfRef = sizer.sizeOfRef(); this.sizeOfInteger = sizer.sizeOf(new Integer(0)); this.sizeOfChar = sizer.sizeOfChar(); this.sizeOfEmptyMessageQueue = sizer.sizeOf(new ConcurrentLinkedQueue<IMessage>()); // Size will be evaluted later based on first m received messages. this.sizeOfMessage = MESSAGE_SIZE; // Default // Get the memory mxBean. MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean(); // Get the heap memory usage. MemoryUsage memoryUsage = memoryMXBean.getHeapMemoryUsage(); long maxHeapSize = memoryUsage.getMax(); LOG.info("[JVM max Heap size] = " + maxHeapSize / MB_SIZE + "MB"); this.sizeOfMessagesSpace = (long) (maxHeapSize * dataPercent * (1.0f - beta)); this.sizeThreshold = (long) (sizeOfMessagesSpace); this.countThreshold = (long) (sizeThreshold / sizeOfMessage); this.countThresholdForBucket = this.countThreshold / (3 * this.hashBucketNumber); LOG.info("[size of Messages Space Threshold] = " + this.sizeThreshold / MB_SIZE + "MB"); LOG.info("[count of Messages In Memory Threshold] = " + this.countThreshold / KB_SIZE + "K"); this.sizeOfMessagesDataInMem = 0; this.countOfMessagesDataInMem = 0; this.totalSizeOfMessages = 0; this.totalCount = 0; this.sizeOfHashMapsInMem = 0; this.fileRoot = new File("/tmp/bcbsp/" + this.jobID.toString() + "/" + "partition-" + this.partitionID); this.messagesDataFile = new File(this.fileRoot + "/" + "MessagesData"); // If the root dir does not exit, create it. if (!this.fileRoot.exists()) { this.fileRoot.mkdirs(); } // If the messages data dir does not exit, create it. if (!this.messagesDataFile.exists()) { this.messagesDataFile.mkdir(); } // Initialize the current accessed bucket index. this.currentBucket = -1; LOG.info("==============================================================="); }
From source file:com.alibaba.otter.node.etl.OtterController.java
public String getHeapMemoryUsage() { MemoryUsage memoryUsage = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage(); return JsonUtils.marshalToString(memoryUsage); }
From source file:com.chinamobile.bcbsp.graph.GraphDataForDisk.java
/** * Initialize the graph data disk manager with job and partitionID. Get the * parameter of graph on disk./*from www .j av a2 s . c o m*/ * @param job * @param partitionID */ public void initialize(BSPJob job, int partitionID) { vertexClass = job.getVertexClass(); edgeClass = job.getEdgeClass(); LOG.info("========== Initializing Graph Data For Disk =========="); this.dataPercent = job.getMemoryDataPercent(); // Default 0.8 this.jobID = job.getJobID(); this.partitionID = partitionID; this.beta = job.getBeta(); this.hashBucketNumber = job.getHashBucketNumber(); LOG.info("[beta] = " + this.beta); LOG.info("[hashBucketNumber] = " + this.hashBucketNumber); this.hashBuckets = new ArrayList<ArrayList<Vertex>>(hashBucketNumber); // So the bitmaps's length decides the maximum nodes of a bucket is // 320*32. this.bitmaps = new ArrayList<ArrayList<Integer>>(hashBucketNumber); this.metaTable = new ArrayList<BucketMeta>(hashBucketNumber); // Initialize the meta table and bitmaps. for (int i = 0; i < hashBucketNumber; i++) { this.hashBuckets.add(null); // init the meta table. BucketMeta meta = new BucketMeta(); meta.superStepCount = -1; meta.onDiskFlag = false; meta.length = 0; meta.lengthInMemory = 0; meta.count = 0; meta.activeCount = 0; metaTable.add(meta); // init the bitmapsCache. ArrayList<Integer> bitmap = new ArrayList<Integer>(Constants.GRAPH_BITMAP_BUCKET_NUM_BYTES); for (int j = 0; j < Constants.GRAPH_BITMAP_BUCKET_NUM_BYTES; j++) { bitmap.add(0); } this.bitmaps.add(bitmap); } // Initialize the size of objects and data structures. //int sizeOfMetaBucket = sizer.sizeOf(new BucketMeta()); //this.sizeOfMetaTable = (sizeOfMetaBucket + sizeOfRef) * hashBucketNumber; int sizeOfBitmap = sizer.sizeOf(new ArrayList<Integer>()); this.sizeOfBitmapsInMem = (sizeOfBitmap + sizeOfRef) * hashBucketNumber; Vertex<?, ?, ?> tmpVertex = null; Edge<?, ?> tmpEdge = null; try { tmpVertex = this.vertexClass.newInstance(); tmpEdge = this.edgeClass.newInstance(); } catch (InstantiationException e) { throw new RuntimeException("[GraphDataForDisk] caught:", e); } catch (IllegalAccessException e) { throw new RuntimeException("[GraphDataForDisk] caught:", e); } this.sizeOfVertex = sizer.sizeOf(tmpVertex); this.sizeOfEdge = sizer.sizeOf(tmpEdge); LOG.info("[Default initial size of Vertex] = " + this.sizeOfVertex + "B"); LOG.info("[Default initial size of Edge] = " + this.sizeOfEdge + "B"); // Get the memory mxBean. MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean(); // Get the heap memory usage. MemoryUsage memoryUsage = memoryMXBean.getHeapMemoryUsage(); long maxHeapSize = memoryUsage.getMax(); LOG.info("[JVM max Heap size] = " + maxHeapSize / MB_SIZE + "MB"); this.sizeOfGraphSpace = (long) (maxHeapSize * dataPercent * beta); this.sizeThreshold = (sizeOfGraphSpace); this.sizeOfGraphDataInMem = 0; this.sizeForAll = 0; this.totalSizeOfVertex = 0; this.totalCountOfVertex = 0; this.totalSizeOfEdge = 0; this.totalCountOfEdge = 0; this.sortedBucketIndexList = new int[hashBucketNumber]; this.fileRoot = new File("/tmp/bcbsp/" + this.jobID.toString() + "/" + "partition-" + this.partitionID); this.graphDataFile = new File(this.fileRoot + "/" + "GraphData"); LOG.info("[size of Graph Data Space] = " + this.sizeOfGraphSpace / MB_SIZE + "MB"); LOG.info("[threshold of Graph Data] = " + this.sizeThreshold / MB_SIZE + "MB"); LOG.info("======================================================"); }
From source file:com.chinamobile.bcbsp.comm.ProducerTool.java
/** Run method of Thread. */ public final void run() { while (true) { while (this.idle) { if (this.completed) { return; }/*from w w w.ja v a 2 s . co m*/ if (this.noMoreMessagesFlag) { this.superStepCounter++; this.noMoreMessagesFlag = false; // LOG.info("Test Progress: from " + (this.superStepCounter - 1) + // " to " + this.superStepCounter); } try { Thread.sleep(this.sleepTime); } catch (InterruptedException e) { LOG.error("[ProducerTool] to " + this.hostNameAndPort + " has been interrupted for ", e); return; } } if (this.hostNameAndPort == null) { LOG.error("Destination hostname is null."); return; } if (this.messageQueue == null) { LOG.error("Message queue for ProducerTool is null."); return; } this.messageCount = 0; this.connectTime = 0; this.sendTime = 0; while (true) { if (this.reconnectCount == ProducerTool.RECONNECTTHRESHOLD) { break; } try { if (this.newHostNameAndPort) { // Should create new connection. if (connection != null) { try { connection.close(); } catch (Throwable ignore) { LOG.warn("[ConsumerTool] run connection " + ignore); } } long start = System.currentTimeMillis(); /** Clock */ // Make the destination broker's url. this.url = "tcp://" + this.hostNameAndPort; // Create the connection. // ActiveMQConnectionFactory connectionFactory = new // ActiveMQConnectionFactory( // user, password, url); BSPActiveMQConnFactory connectionFactory = new BSPActiveMQConnFactoryImpl(); connectionFactory.activeMQConnFactoryMethod(url); connectionFactory.setCopyMessageOnSend(false); connection = connectionFactory.createConnection(); connection.start(); // Create the session session = connection.createSession(transacted, Session.AUTO_ACKNOWLEDGE); this.connectTime += (System.currentTimeMillis() - start); /* Clock */ this.newHostNameAndPort = false; start = System.currentTimeMillis(); /* Clock */ destination = session.createQueue(subject); // Create the producer. producer = session.createProducer(destination); if (persistent) { producer.setDeliveryMode(DeliveryMode.PERSISTENT); } else { producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); } if (timeToLive != 0) { producer.setTimeToLive(timeToLive); } this.connectTime += (System.currentTimeMillis() - start); } // Start sending messages sendLoopOptimistic(session, producer); this.idle = true; break; } catch (Exception e) { this.reconnectCount++; if (this.reconnectCount == 1) { LOG.error("[ProducerTool] to " + this.hostNameAndPort + " caught: ", e); } LOG.info("[ProducerTool] to " + this.hostNameAndPort + " is reconnecting for " + this.reconnectCount + "th time."); LOG.info("---------------- Memory Info ------------------"); MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean(); MemoryUsage memoryUsage = memoryMXBean.getHeapMemoryUsage(); long used = memoryUsage.getUsed(); long committed = memoryUsage.getCommitted(); LOG.info("[JVM Memory used] = " + used / MB_SIZE + "MB"); LOG.info("[JVM Memory committed] = " + committed / MB_SIZE + "MB"); LOG.info("-----------------------------------------------"); try { Thread.sleep(this.sleepTime); } catch (InterruptedException e1) { LOG.error("[ProducerTool] caught: ", e1); } } } LOG.info("[ProducerTool] to " + this.hostNameAndPort + " has sent " + this.messageCount + " messages totally! (with " + this.messageQueue.size() + " messages lost!)"); this.sender.addConnectTime(this.connectTime); /* Clock */ this.sender.addSendTime(this.sendTime); /* Clock */ if (this.reconnectCount == ProducerTool.RECONNECTTHRESHOLD) { LOG.info("[ProducerTool] to " + this.hostNameAndPort + " has reconnected for " + this.reconnectCount + " times but failed!"); this.isFailed = true; break; } } }
From source file:com.datatorrent.contrib.hdht.HadoopFilePerformanceTest.java
@Test public void testMapFileRead() throws Exception { logger.info("Reading {} with {} key/value pairs", Testfile.MAPFILE.filename(), String.format("%,d", testSize)); writeMapFile();//ww w . ja v a2 s . c o m Text key = new Text(); Text value = new Text(); writeMapFile(); // Set amount of memory to use for buffer float bufferPercent = 0.25f; int bufferSize = (int) (ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getMax() * bufferPercent); MapFile.Reader reader = new MapFile.Reader(Testfile.MAPFILE.filepath(), conf, SequenceFile.Reader.bufferSize(bufferSize)); startTimer(); reader.reset(); while (reader.next(key, value)) { //logger.debug("read key:{} value:{}", key, value); } logger.info("Duration for reader.next() SEQUENTIAL keys: {}", stopTimer(Testfile.MAPFILE, "READ-SEQ")); startTimer(); reader.reset(); for (int i = 0; i < testSize; i++) { key.set(getKey(i)); reader.get(key, value); //logger.debug("{}:{}", key, value); } logger.info("Duration for reader.get(key) SEQUENTIAL keys: {}", stopTimer(Testfile.MAPFILE, "READ-SEQ-ID")); Random random = new Random(); startTimer(); for (int i = 0; i < testSize; i++) { key.set(getKey(random.nextInt(testSize))); reader.get(key, value); //logger.debug("{}:{}", key, value); } logger.info("Duration for reader.get(key) RANDOM keys: {}", stopTimer(Testfile.MAPFILE, "READ-RAND")); reader.close(); }
From source file:com.obergner.hzserver.ServerInfo.java
private MemoryMXBean memory() { return ManagementFactory.getMemoryMXBean(); }
From source file:com.knowbout.cc2nlp.server.CCEventServiceImpl.java
private void checkStats() { long timestamp = new Date().getTime(); String day = getFileDate(timestamp); if (!day.equals(currentDay)) { if (statsFile != null) { statsFile.println("</table></body></html>"); statsFile.close();/* ww w .ja va 2s.c o m*/ statsFile = null; } currentDay = day; } if (hostname == null) { try { hostname = InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e) { hostname = "UnknownHost"; } } String dirname = documentRoot + "/stats/" + currentDay + "/" + hostname; String statsFileName = dirname + "/nlpprocstats.html"; int interval = 5; // minutes try { if (statsFile == null) { File dir = new File(dirname); if ((!dir.exists()) && (!dir.mkdirs())) { throw new IOException("Error creating directory " + dirname); } File file = new File(statsFileName); if (file.exists()) { statsFile = new PrintStream(new FileOutputStream(statsFileName, true)); statsFile.println("<tr><td colspan='5'>Restart</td></tr>"); } else { statsFile = new PrintStream(new FileOutputStream(statsFileName)); String title = "NLP Process (tomcat) status for " + currentDay; statsFile.println("<html><head><title>" + title + "</title></head>"); statsFile.println("<body><h1>" + title + "</h1>"); statsFile.println("<table border='1'>"); statsFile.println("<tr>"); statsFile.println( "<th colspan='2'>" + interval + " Minute Intervals</th><th colspan='3'>Memory</th>"); statsFile.println("</tr>"); statsFile.println("<tr>"); statsFile.println("<th>Timestamp</th>"); statsFile.println("<th>Time</th>"); statsFile.println("<th>Used</th>"); statsFile.println("<th>Committed</th>"); statsFile.println("<th>Max<th>"); statsFile.println("</tr>"); } } if ((timestamp - lastWrite) > (interval * 60 * 1000)) { lastWrite = timestamp; Calendar cal = Calendar.getInstance(); cal.setTimeZone(TimeZone.getTimeZone("GMT")); cal.setTimeInMillis(timestamp); String time = String.format("%1$tH:%1$tM:%1$tS", cal); MemoryMXBean memoryBean = ManagementFactory.getMemoryMXBean(); MemoryUsage memory = memoryBean.getHeapMemoryUsage(); statsFile.print("<tr>"); statsFile.print("<td>" + timestamp + "</td>"); statsFile.print("<td>" + time + "</td>"); statsFile.format("<td>%,d</td>", memory.getUsed()); statsFile.format("<td>%,d</td>", memory.getCommitted()); statsFile.format("<td>%,d</td>", memory.getMax()); statsFile.println("</tr>"); } } catch (IOException e) { log.error("Error opening or writing to " + statsFileName, e); } }