-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmemory.cfm
102 lines (95 loc) · 4.09 KB
/
memory.cfm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<style>
.progress { height:26px; }
.progress .progress-bar { line-height: 26px; font-size:16px; }
.footer {
position: absolute;
bottom: 0;
width: 100%;
padding-top: 20px;
height: 160px;
background-color: #f5f5f5;
}
</style>
</head>
<body>
<cfset runtime = CreateObject("java","java.lang.Runtime").getRuntime()>
<cfset freeAllocatedMemory = runtime.freeMemory() / 1024 / 1024>
<cfset currentHeapSize = runtime.totalMemory() / 1024 / 1024>
<cfset memoryInUse = currentHeapSize-freeAllocatedMemory>
<cfset maxHeapSize = runtime.maxMemory() / 1024 / 1024>
<cfset percentUsed = round( (memoryInUse / currentHeapSize) * 100 )>
<cfset percentFree = round( (freeAllocatedMemory / currentHeapSize) * 100 )>
<cfset percentAllocated = round( (currentHeapSize / maxHeapSize) * 100 )>
<div class="container">
<cfoutput>
<h1>JVM Memory Metrics</h1>
<div class="jumbotron">
<div class="row">
<div class="col-sm-3 text-right">Memory Usage:</div>
<div class="col-sm-9"><strong>#round(memoryInUse)#mb #percentUsed#%</strong> <small class="text-muted">of heap memory is in use</small></div>
</div>
<div class="row">
<div class="col-sm-3 text-right">Free Allocated Memory:</div>
<div class="col-sm-9"><strong>#round(freeAllocatedMemory)#mb #percentFree#%</strong> <small class="text-muted">of heap memory is allocated but not in use</small></div>
</div>
<div class="row">
<div class="col-sm-3 text-right">Current Heap Size:</div>
<div class="col-sm-9"><strong>#round(currentHeapSize)#mb #percentAllocated#%</strong> <small class="text-muted">of heap memory is allocated</small></div>
</div>
<div class="row">
<div class="col-sm-3 text-right">Max Heap Size:</div>
<div class="col-sm-9"><strong>#round(maxHeapSize)#mb</strong> <small class="text-muted">is the maximum amount of memory that <cfif structKeyExists(server, "lucee")>Lucee<cfelse>ColdFusion</cfif> can use. </small></div>
</div>
</div>
<h2>Current Heap Memory Usage</h2>
<div class="progress">
<div class="progress-bar <cfif percentUsed GT 90>progress-bar-danger<cfelseif percentUsed GT 50>bg-warning<cfelse>bg-info</cfif> text-large" role="progressbar" style="width:#int(percentUsed)#%">
#percentUsed#% In Use
</div>
<div class="progress-bar bg-success text-large" role="progressbar" style="width:#int(100-int(percentUsed))#%">
#percentFree#% Free
</div>
</div>
<h2>Heap Allocation</h2>
<div class="progress">
<div class="progress-bar bg-info" role="progressbar" style="width:#int(percentAllocated)#%">
<div class="text-large">#percentAllocated#% Allocated</div>
</div>
</div>
<div class="text-muted">
<cfif percentAllocated LT 100>
The current heap size is #round(currentHeapSize)#mb, however the JVM is configured to allow it to grow to #round(maxHeapSize)#mb.
<cfelse>
The current heap size is #round(currentHeapSize)#mb is equal to the max heap size #round(maxHeapSize)#mb. This
simply means that the JVM is not going to grow at runtime (which can be good for performance).
</cfif>
Even if your server operating system has more memory, it will not go above this configurable limit.
</div>
</cfoutput>
</div>
<footer class="footer">
<div class="container">
<div class="row">
<div class="col-sm-4 text-right">
<a href="https://foundeo.com/"><img src="https://foundeo.com/images/foundeo.png" alt="foundeo"></a>
</div>
<div class="col-sm-8">
<strong>Built by Foundeo Inc.</strong>
<div class="text-muted">
A CFML Products & Services Company.
<br>
<a href="https://foundeo.com/consulting/coldfusion/">ColdFusion Consulting</a> |
<a href="https://fixinator.app/">Fixinator</a> |
<a href="https://foundeo.com/hack-my-cf/">HackMyCF</a> |
<a href="https://foundeo.com/security/fuseguard/">FuseGuard</a>
</div>
</div>
</div>
</div>
</footer>
</body>
</html>