You are viewing a plain text version of this content. The canonical link for it is here.
Posted to kato-commits@incubator.apache.org by mo...@apache.org on 2009/05/20 12:20:58 UTC

svn commit: r776674 - /incubator/kato/trunk/org.apache.kato.example.tomcat/WebContent/hprofDump.jsp

Author: monteith
Date: Wed May 20 12:20:58 2009
New Revision: 776674

URL: http://svn.apache.org/viewvc?rev=776674&view=rev
Log:
Add hprofDump.jsp - generates HProf dumps.

Added:
    incubator/kato/trunk/org.apache.kato.example.tomcat/WebContent/hprofDump.jsp   (with props)

Added: incubator/kato/trunk/org.apache.kato.example.tomcat/WebContent/hprofDump.jsp
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato.example.tomcat/WebContent/hprofDump.jsp?rev=776674&view=auto
==============================================================================
--- incubator/kato/trunk/org.apache.kato.example.tomcat/WebContent/hprofDump.jsp (added)
+++ incubator/kato/trunk/org.apache.kato.example.tomcat/WebContent/hprofDump.jsp Wed May 20 12:20:58 2009
@@ -0,0 +1,81 @@
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
+    pageEncoding="ISO-8859-1"%>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<!-- 
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.    
+ -->
+<!-- 
+	Generates an hprof file using JMX. 
+	Do not place this on production servers.
+ -->
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<title>HProf Dump</title>
+</head>
+<body>
+Generates an hprof file from the current heap state.
+<pre>
+JVM:
+<%
+	out.write(System.getProperty("java.vm.vendor") + ", "
+			+ System.getProperty("java.vm.name") + ", "
+			+ System.getProperty("java.vm.version"));
+%>
+</pre>
+
+<form name="Dump" method="post" action="">
+<input type="submit" value="hprof" name="Dump"/>
+</form>
+<%@page import="javax.management.*,java.lang.management.ManagementFactory,java.io.File" %>
+<%
+	String dumpType = request.getParameter("Dump");
+
+	if ("hprof".equals(dumpType)) {
+		MBeanServer mbeanServer = ManagementFactory
+				.getPlatformMBeanServer();
+		String fileName = System.getProperty("user.dir")+File.separatorChar+"hprofDump"+
+					System.currentTimeMillis()+".hprof";
+		
+		out.write("Generating hprof file \""+fileName+"\"");
+		out.flush();
+		
+		try {
+			mbeanServer
+					.invoke(
+							ObjectName
+									.getInstance("com.sun.management:type=HotSpotDiagnostic"),
+							"dumpHeap", new Object[] {
+									fileName, true },
+							new String[] { "java.lang.String",
+									"boolean" });
+		} catch (InstanceNotFoundException e) {
+			e.printStackTrace();
+		} catch (MalformedObjectNameException e) {
+			e.printStackTrace();
+		} catch (MBeanException e) {
+			e.printStackTrace();
+		} catch (ReflectionException e) {
+			e.printStackTrace();
+		} catch (NullPointerException e) {
+			e.printStackTrace();
+		}
+	}
+%>
+</body>
+</html>
\ No newline at end of file

Propchange: incubator/kato/trunk/org.apache.kato.example.tomcat/WebContent/hprofDump.jsp
------------------------------------------------------------------------------
    svn:mime-type = text/plain