JVM仮想マシンメモリ量詳細表示--JSPページ版

1697 ワード

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JVM memory</title>
</head>
<body>
<%
double total = (Runtime.getRuntime().totalMemory()) / (1024.0 * 1024);
double max = (Runtime.getRuntime().maxMemory()) / (1024.0 * 1024);
double free = (Runtime.getRuntime().freeMemory()) / (1024.0 * 1024);
int totalInt = (int)total;
int maxInt = (int)max;
int freeInt = (int)free;
int realnum = (int)(max - total + free);

out.println("Java              (  JVM       )maxMemory():  <span style='font-size:24px;color:red'>" + maxInt + "</span>  MB<br/><br/>");
out.println("Java          (  JVM       )totalMemory():  <span style='font-size:24px;color:red'>" + totalInt + "</span>  MB<br/><br/>");
out.println("Java           (  JVM    )freeMemory():  <span style='font-size:24px;color:red'>" + freeInt + "</span>  MB<br/><br/>");
out.println("  JVM                 ,  freeMemory()          ,<br/><br/> JVM          freeMemory(),      maxMemory()-totalMemory()+freeMemory()。<br/><br/>");
out.println("JVM      :  <span style='font-size:24px;color:red'>" + realnum + "</span>  MB");
%>
</body>
</html>