1
|
|
2
|
$(document).ready(function(){
|
3
|
|
4
|
function updateMemoryStatus() {
|
5
|
$.getJSON(
|
6
|
"MemoryService.jsp",
|
7
|
function(data){
|
8
|
$("#status").html(''); // make empty
|
9
|
$("#status").append(memoryUsageEntry(data.heapMemoryUsage, data.recommendedMinimumHeap, "HeapUsage", "100%", "#F48B65", "#65B1F4"));
|
10
|
$("#status").append(memoryUsageEntry(data.permGenSpaceUsage, data.recommendedMinimumPermGenSpace, "PermGenSpaceUsage", "100%","#F48B65", "#65B1F4"));
|
11
|
}); // end JSON
|
12
|
|
13
|
|
14
|
setTimeout(function(){
|
15
|
updateMemoryStatus()
|
16
|
}, 1000);
|
17
|
|
18
|
} // end updateMemory
|
19
|
|
20
|
function memoryUsageEntry(memoryUsage, recommended, label, barWidth, cssColorUsed, cssColorMax){
|
21
|
var mb = 1024 * 1024;
|
22
|
var gb = mb * 1024;
|
23
|
var max = memoryUsage.max / mb;
|
24
|
var used = memoryUsage.used / mb;
|
25
|
var percent = used * 100 / max;
|
26
|
var recommendedMB = recommended / mb;
|
27
|
var html = '';
|
28
|
|
29
|
html += '<span class="memory-usage">';
|
30
|
html += label + '(' + used + ' of ' + max+ ' MB, recommended: ' + recommendedMB + ' MB) ';
|
31
|
html += '<div style="height: 100%; width:' + barWidth + ';background-color:' + cssColorMax + '">';
|
32
|
html += '<div style="background-color:' + cssColorUsed + '; width:' + percent + '%"> </div></div></span>';
|
33
|
|
34
|
return html;
|
35
|
}
|
36
|
|
37
|
updateMemoryStatus()
|
38
|
|
39
|
});
|