1234567891011121314151617181920212223 |
- <%@ page import="java.text.DecimalFormat" %>
- <%@page contentType="text/html" pageEncoding="UTF-8" %>
- <!DOCTYPE>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title>JVM memory</title>
- </head>
- <body>
- <%
- final double mb = 1024.0 * 1024;
- final Runtime runtime = Runtime.getRuntime();
- double total = (runtime.totalMemory()) / mb;
- double max = (runtime.maxMemory()) / mb;
- double free = (runtime.freeMemory()) / mb;
- DecimalFormat format = new DecimalFormat("0.##");
- out.println("当前JVM的最大可用内存(maxMemory): " + format.format(max) + "MB<br/>");
- out.println("当前JVM占用的内存总数(totalMemory): " + format.format(total) + "MB<br/>");
- out.println("当前JVM空闲内存(freeMemory): " + format.format(free) + "MB<br/>");
- out.println("JVM实际可用内存: " + format.format(max - total + free) + "MB<br/>");
- %>
- </body>
- </html>
|