1
14
15 package com.liferay.portal.kernel.util;
16
17 import java.io.IOException;
18
19
24 public class HeapUtil {
25
26 public static void heapDump(boolean live, boolean binary, String file) {
27 int processId = ProcessUtil.getProcessId();
28
29 StringBundler sb = new StringBundler(7);
30
31 sb.append("jmap -dump:");
32
33 if (live) {
34 sb.append("live,");
35 }
36
37 if (binary) {
38 sb.append("format=b,");
39 }
40
41 sb.append("file=");
42 sb.append(file);
43 sb.append(StringPool.SPACE);
44 sb.append(processId);
45
46 try {
47 Runtime runtime = Runtime.getRuntime();
48
49 runtime.exec(sb.toString());
50 }
51 catch (IOException ioe) {
52 throw new RuntimeException("Unable to perform heap dump", ioe);
53 }
54 }
55
56 }