当前位置: 首页>>代码示例>>Java>>正文


Java HotSpotDiagnosticMXBean.dumpHeap方法代码示例

本文整理汇总了Java中com.sun.management.HotSpotDiagnosticMXBean.dumpHeap方法的典型用法代码示例。如果您正苦于以下问题:Java HotSpotDiagnosticMXBean.dumpHeap方法的具体用法?Java HotSpotDiagnosticMXBean.dumpHeap怎么用?Java HotSpotDiagnosticMXBean.dumpHeap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.management.HotSpotDiagnosticMXBean的用法示例。


在下文中一共展示了HotSpotDiagnosticMXBean.dumpHeap方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: dumpTo

import com.sun.management.HotSpotDiagnosticMXBean; //导入方法依赖的package包/类
/**
 * Dumps the heap to the outputFile file in the same format as the hprof heap dump.
 * If this method is called remotely from another process, the heap dump output is written to a file named outputFile on the machine where the target VM is running. If outputFile is a relative path, it is relative to the working directory where the target VM was started.
 * @param res Resource to write the .hprof file.
 * @param live  if true dump only live objects i.e. objects that are reachable from others
 * @throws IOException 
 */
public static void dumpTo(Resource res, boolean live) throws IOException {
	MBeanServer mbserver = ManagementFactory.getPlatformMBeanServer();
	HotSpotDiagnosticMXBean mxbean = ManagementFactory.newPlatformMXBeanProxy( mbserver, "com.sun.management:type=HotSpotDiagnostic", HotSpotDiagnosticMXBean.class );
	
	String path;
	Resource tmp=null;
	if(res instanceof FileResource) path=res.getAbsolutePath();
	else {
		tmp=SystemUtil.getTempFile("hprof",false);
		path=tmp.getAbsolutePath();
	}
	try{
		// it only 
		mxbean.dumpHeap(path, live);
	}
	finally{
		if(tmp!=null && tmp.exists()){
			tmp.moveTo(res);
		}
	}
	
  	}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:30,代码来源:HeapDumper.java

示例2: fillMemory

import com.sun.management.HotSpotDiagnosticMXBean; //导入方法依赖的package包/类
private static void fillMemory() throws ParseException, IOException {
	setTimeZone("Asia/Seoul");
	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
	sdf.setTimeZone(timeZoneCache);

	Date begin = getDay(sdf.parse("1900-01-01"));
	Date end = getDay(sdf.parse("2101-01-01"));
	Calendar c = Calendar.getInstance(timeZoneCache);
	c.setTime(begin);
	c.set(Calendar.MILLISECOND, 0);
	while (c.getTime().before(end)) {
		getDay(c.getTime());
		c.add(Calendar.SECOND, 10);
		if (c.getTime().getTime() % 86400000L == 0)
			System.out.println(sdf.format(c.getTime()));
	}

	MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
	HotSpotDiagnosticMXBean bean =
			ManagementFactory.newPlatformMXBeanProxy(platformMBeanServer,
					"com.sun.management:type=HotSpotDiagnostic", HotSpotDiagnosticMXBean.class);
	bean.dumpHeap("E:\\w\\araqne\\CalendarDump.hprof", true);
}
 
开发者ID:araqne,项目名称:logdb,代码行数:24,代码来源:DateUtil.java

示例3: dumpHeap

import com.sun.management.HotSpotDiagnosticMXBean; //导入方法依赖的package包/类
public static boolean dumpHeap(String fileName, boolean live) {
	MBeanServer server = ManagementFactory.getPlatformMBeanServer();
	try {
		logger.fine("Taking heap dump..");
		HotSpotDiagnosticMXBean hotspotMBean =
			ManagementFactory.newPlatformMXBeanProxy(server,
			"com.sun.management:type=HotSpotDiagnostic",
			HotSpotDiagnosticMXBean.class);

		hotspotMBean.dumpHeap(fileName, live);

		logger.fine("Heap dump done");
		return true;
	} catch (Throwable e) {
		logger.log(Level.WARNING, "Error: " + e, e);
	}

	return false;
}
 
开发者ID:QuickServerLab,项目名称:QuickServer-Main,代码行数:20,代码来源:JvmUtil.java

示例4: dumpHeap

import com.sun.management.HotSpotDiagnosticMXBean; //导入方法依赖的package包/类
/**
 * Dumps heap to the specified path.
 * Logs where the heap dump will be written.
 * Logs a warning if there was a problem preventing the heap dump from being successfully created.
 * @param path Where to put the heap dump.
 */
public static void dumpHeap(final Path path) {
    LOG.info("writing heap dump to {}", path);
    final HotSpotDiagnosticMXBean bean = getBean(HotSpotDiagnosticMXBean.class);
    if (bean == null) {
        return;
    }
    try {
        bean.dumpHeap(path.toString(), true);
    } catch (IOException e) {
        LOG.warn("error writing heap dump", e);
    }
}
 
开发者ID:opentable,项目名称:otj-jvm,代码行数:19,代码来源:Memory.java

示例5: dumpHeap

import com.sun.management.HotSpotDiagnosticMXBean; //导入方法依赖的package包/类
/**
 * Write a Java heap dump to the named file.  If the dump file exists, this method will
 * fail.
 *
 * @param dumpLiveObjects if {@code true}, only "live" (reachable) objects are dumped;
 *                        if {@code false}, all objects in the heap are dumped
 * @param dumpName the name of the file to which the heap dump is written; relative names
 *                 are relative to the current directory ({@code user.dir}).  If the value
 *                 of {@code dumpName} does not end in {@code .hprof}, it is appended.
 *
 * @throws IOException if thrown while loading the HotSpot Diagnostic MXBean or writing the heap dump
 *
 * @see <a href="http://docs.oracle.com/javase/8/docs/jre/api/management/extension/com/sun/management/HotSpotDiagnosticMXBean.html">
 *        com.sun.management.HotSpotDiagnosticMXBean</a>
 */
public static void dumpHeap(final boolean dumpLiveObjects, String dumpName) throws IOException {
  if (dumpName == null) {
    throw new NullPointerException("dumpName");
  }

  if (!dumpName.endsWith(".hprof")) {
    dumpName += ".hprof";
  }

  final MBeanServer server = ManagementFactory.getPlatformMBeanServer();
  final HotSpotDiagnosticMXBean hotSpotDiagnosticMXBean =
      ManagementFactory.newPlatformMXBeanProxy(server, HOTSPOT_DIAGNOSTIC_MXBEAN_NAME, HotSpotDiagnosticMXBean.class);
  hotSpotDiagnosticMXBean.dumpHeap(dumpName, dumpLiveObjects);
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:30,代码来源:Diagnostics.java


注:本文中的com.sun.management.HotSpotDiagnosticMXBean.dumpHeap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。