2017년 5월 20일 토요일

서버측 메모리 사이즈 확인

<%@ page import = "java.text.NumberFormat"%>
<%@ page import = "java.text.DecimalFormat"%>
<%@ page import = "java.text.NumberFormat"%>
<meta http-equiv="Refresh" content="1;url=test.jsp">
<%!
String getMoneyFormat (String str) {
    double result = Double.parseDouble (str);
    NumberFormat nf = NumberFormat.getInstance ();
    if (nf instanceof DecimalFormat) {
        ((DecimalFormat) nf).setDecimalSeparatorAlwaysShown (false);
    }
    return nf.format((int) result);
}
%>
<%
Runtime rt = Runtime.getRuntime();
%>
Total size: <%=getMoneyFormat (Long.toString (rt.totalMemory()))%>
<br>free size: <%=getMoneyFormat (Long.toString (rt.freeMemory()))%>
<br>Heap size: <%=getMoneyFormat (Long.toString (rt.totalMemory()-rt.freeMemory()))%>