【问题标题】:Display memory info nicely in a gsp - better numeric display在 gsp 中很好地显示内存信息 - 更好的数字显示
【发布时间】:2013-10-01 19:53:23
【问题描述】:

我想在 GSP 中显示一些关于我的 JVM 的内存信息。

我愿意:

 <table>
 <tr><td>Total memory</td><td><%=Runtime.runtime.totalMemory()%></td></tr>
 <tr><td>Free memory</td><td><%=Runtime.runtime.freeMemory()%></td></tr>
 <tr><td>Max memory</td><td><%=Runtime.runtime.maxMemory()%></td></tr>
 <table>

没关系。它给了我诸如 504385536 之类的值。我宁愿只显示 504Meg 或 504.3Meg 之类的东西。这可能吗?

谢谢

【问题讨论】:

标签: jsp grails gsp


【解决方案1】:

除以1024*1024并加上'MB'后缀

<%=Runtime.runtime.totalMemory()/(1024*1024)%>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-10-16
    • 1970-01-01
    • 2019-07-28
    • 1970-01-01
    • 2012-09-15
    • 1970-01-01
    • 2019-10-22
    • 1970-01-01
    相关资源
    最近更新 更多