heap.php
2.37 KB
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
103
104
105
106
<?php
/**
* Summary of heap
*/
require_once "WEB-INF/php/inc.php";
$heap = @new Java("com.caucho.profile.Heap");
$mbeanServer = new MBeanServer();
$server = $mbeanServer->lookup("resin:type=Server");
$server_id = $server->Id;
if (! $server_id)
$server_id = "default";
$title = "Resin: Heap $server_Id";
if (! $heap)
$title .= " - not available";
?>
<?php display_header("heap.php", $title, $server) ?>
<?php
$is_heap_available_heap = false;
if ($heap) {
echo "<form action='heap.php' method='post'>";
echo "<input type='submit' name='action' value='dump heap'>";
echo "</form>";
if ($_POST['action'] == 'dump heap') {
$entries = $heap->dump();
$is_heap_available = sizeof($entries) > 0;
}
else {
$entries = $heap->lastDump();
$is_heap_available = true;
}
}
if (sizeof($entries) > 0) {
$topSize = $entries[0]->getTotalSize();
echo "<table class='data'>";
echo "<tr>\n";
echo " <th>rank</th>\n";
echo " <th>self+desc</th>\n";
echo " <th>self</th>\n";
echo " <th>desc</th>\n";
echo " <th>count</th>\n";
echo " <th>class</th>\n";
echo "</tr>\n";
for ($i = 0; $i < sizeof($entries); $i++) {
$entry = $entries[$i];
echo "<tr class='" . row_style($i) . "'>";
echo "<td>";
printf("%.4f", $entry->getTotalSize() / $topSize);
echo "</td>";
echo "<td align='right'>";
printf("%.3fM", $entry->getTotalSize() / (1024 * 1024));
echo "</td>";
echo "<td align='right'>";
printf("%.3fM", $entry->getSelfSize() / (1024 * 1024));
echo "</td>";
echo "<td align='right'>";
printf("%.3fM", $entry->getChildSize() / (1024 * 1024));
echo "</td>";
echo "<td align='right'>";
printf("%d", $entry->getCount());
echo "</td>";
echo "<td>";
echo "{$entry->getClassName()}";
echo "</td>";
echo "</tr>\n";
}
echo "</table>\n";
}
else if (! $is_heap_available) {
echo "<h2>Heap dump is not available</h2>\n";
echo "<p>The heap dump requires Resin Professional and compiled JNI. It\n";
echo "also requires an '-agentlib:resin' JVM argument:</p>\n";
echo "<pre>\n";
echo "<resin ...>\n";
echo " <cluster id='...'>\n";
echo " <server id='...'>\n";
echo " ...\n";
echo " <jvm-arg>-agentlib:resin</jvm-arg>\n";
echo " </server>\n";
echo " </cluster>\n";
echo "</resin>\n";
echo "</pre>\n";
}
display_footer("heap.php");
?>